简体   繁体   中英

On clicking link, focus on svg element

I just started working with SVG images and I was wondering if it is possible to create a text link that when on click, it focuses on a specific element.

For example, I have a text that is located on the far left of my screen and a circle element that can only be seen if I scroll to the far right. And when I click on said text, it would then scroll or jump to that element.

I'm still somewhat a beginner at this, so any help would be greatly appreciated.

If you want to snap to an element, you can always do the following.

<div id="snap-to-me"></div>

<a href="#snap-to-me">SNAP</a>

Upon clicking the link, the page will try to find an element with that id, and snap to it.

If you want animated scrolling, I suggest you checkout a library that supports it. jQuery being an obvious, good choice.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM