Skip to content

Instantly share code, notes, and snippets.

@NickTomlin
Created June 7, 2013 14:11
Show Gist options
  • Save NickTomlin/5729537 to your computer and use it in GitHub Desktop.
Save NickTomlin/5729537 to your computer and use it in GitHub Desktop.
Current page.js
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