Skip to content

Instantly share code, notes, and snippets.

@codenameEli
Created January 14, 2016 16:35
Show Gist options
  • Save codenameEli/bba38d881d18b455e92a to your computer and use it in GitHub Desktop.
Save codenameEli/bba38d881d18b455e92a to your computer and use it in GitHub Desktop.
Adds a 'state' class to style upon for the navigation on Wordpress. Helpful for 2 or more levels deep navigation.
jQuery(document).ready(function($) {
var NavHoverClasses = {
init: function() {
this.classes = {
'enter': 'currently-active'
};
this.addListeners();
},
addListeners: function() {
var self = this;
$('nav.nav-primary').on('mouseenter', '.menu-item', function() {
$(this).addClass(self.classes.enter);
});
$('nav.nav-primary').on('mouseleave', '.menu-item', function() {
$(this).removeClass(self.classes.enter);
});
}
}
NavHoverClasses.init();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment