Skip to content

Instantly share code, notes, and snippets.

@Njengah
Created March 15, 2020 05:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Njengah/a68bb0a3e963e636998150fe8fd74881 to your computer and use it in GitHub Desktop.
Save Njengah/a68bb0a3e963e636998150fe8fd74881 to your computer and use it in GitHub Desktop.
Add active menu class based on URL using jQuery more explanation here - https://njengah.com/add-active-navigation-class-based-on-url/
/**
* Add active menu class based on URL using jQuery
*/
jQuery(function($) {
var path = window.location.href;
$('ul a').each(function() {
if (this.href === path) {
$(this).addClass('active');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment