Blazzike Blazzike - 1 year ago 72
jQuery Question

Current Anchor has Different Colour and scrolls?

I am curious on how to set the current anchor href elements as a different colour to the others.

So basically if there is an a element with a href to #home and the current anchor is #home then it should be red and the others should be white.

I'd prefer to do this with HTML, CSS, jQuery, JavaScript.

The anchors also have to scroll to the correct element.

Thanks in advance,

Answer Source

I think you looking for the CSS :target() selector.

You can find more details about here:

Hope this was what you were looking for. ;)