Skip to content

Instantly share code, notes, and snippets.

@richgcook
Last active November 19, 2015 14:45
Show Gist options
  • Select an option

  • Save richgcook/d848f33e80e8d9dd05a5 to your computer and use it in GitHub Desktop.

Select an option

Save richgcook/d848f33e80e8d9dd05a5 to your computer and use it in GitHub Desktop.
Active body/menu links
$('ul.navigation-list li, ul.tag-list li').each(function() {
var classes = this.classList;
for (var i=0,len=classes.length; i<len; i++) {
if ($('body').hasClass(classes[i])) {
$(this).addClass('active');
}
}
});
$('.menu-section-container ul li').each(function() {
var class_attr = $(this).attr('class');
if ( class_attr != undefined ) {
var classes = class_attr.split(/\s+/);
for (var i=0,len=classes.length; i<len; i++) {
if ($('body').hasClass(classes[i])) {
$(this).addClass('active');
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment