MKR
MKR

Reputation: 13

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.

Upvotes: 1

Views: 456

Answers (1)

GMchris
GMchris

Reputation: 5648

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.

Upvotes: 1

Related Questions