Skip to content

Instantly share code, notes, and snippets.

@joeldbirch
Created July 13, 2012 06:33
Show Gist options
  • Save joeldbirch/3103140 to your computer and use it in GitHub Desktop.
Save joeldbirch/3103140 to your computer and use it in GitHub Desktop.
Add current class to ancestor li elements prior to initialising Superfish
$(document).ready(function(){
//this will be used more than once so save it to a variable
var menu = $('ul.sf-menu')
//given that you already seem to have the current page marked with 'current' on the relevant li,
//find that li, then find any ancestors of it and add 'current' to them also
menu.find('.current').parents('li').addClass('current');
//once you have done that, then initialise Superfish
menu.superfish({
pathClass: 'current'
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment