Skip to content
Advertisement

How to add class for ACTIVE URL in sidebar?

My code:

JavaScript

But it doesn’t work, where did I go wrong?

Advertisement

Answer

The HREF of links will automatically include the current domain when accessing via javascript, so you can just directly compare to window.location.href

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement