Skip to content

Instantly share code, notes, and snippets.

@ryanve
Last active December 7, 2016 11:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ryanve/6153436 to your computer and use it in GitHub Desktop.
Save ryanve/6153436 to your computer and use it in GitHub Desktop.
Add `.current` class to anchors that link to the current URL.
//gist.github.com/ryanve/6153436
(function(anchors, url, i, a) {
while ((a = anchors[i++]) && a.classList)
a.href === url && a.classList.add('current');
}(document.getElementsByTagName('a'), location.href, 0));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment