Blazzike Blazzike - 4 months ago 8
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,
Blazzike.

Answer

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

You can find more details about here: http://www.w3schools.com/cssref/sel_target.asp

Hope this was what you were looking for. ;)

Comments