Created
June 7, 2013 14:11
-
-
Save NickTomlin/5729537 to your computer and use it in GitHub Desktop.
Current page.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var page = window.location.pathname; // '/our-product' | |
var link = document.querySelector('.nav-main a[href="'+ page +'"]'); | |
if (link) link.className += " active"; // maybe there is a better way to test if (link actually exists), it seems to fail silenetly regardless, so probably okay |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment