Skip to content

Instantly share code, notes, and snippets.

@geoffyuen
Created January 29, 2014 21:15
Show Gist options
  • Select an option

  • Save geoffyuen/8697367 to your computer and use it in GitHub Desktop.

Select an option

Save geoffyuen/8697367 to your computer and use it in GitHub Desktop.
Adds .active class to an <a> if the url (page and extension only) == the a.href inside .site-menu class
$('.active').removeClass('active');
$('.site-menu a[href$="' + location.pathname.substring().split("/").pop() + '"]').addClass('active');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment