Skip to content

Instantly share code, notes, and snippets.

@Narga
Created June 7, 2012 02:28
Show Gist options
  • Save Narga/2886171 to your computer and use it in GitHub Desktop.
Save Narga/2886171 to your computer and use it in GitHub Desktop.
Wordpress - Dropdown Navigation jQuery Code
if(!jQuery.browser.msie){jQuery("ul.topnav").css({opacity:"0.95"});} // IE - 2nd level Fix
jQuery(".topnav > li > ul").css({display: "none"}); // Opera Fix
jQuery("ul.sub-menu").parent().append("<div>&nbsp;</div>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
jQuery("ul.sub-menu li.menu-item").append("<span>&#187;</span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
jQuery("ul.menu li a").hover(function() { //When trigger is clicked...
//Following events are applied to the subnav itself (moving subnav up and down)
jQuery(this).parent().find("ul.sub-menu").slideDown('fast').show(400); //Drop down the subnav on hover
jQuery(this).parent().hover(function() {
}, function(){
jQuery(this).parent().find("ul.sub-menu").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
});
//Following events are applied to the trigger (Hover events for the trigger)
}).hover(function() {
jQuery(this).addClass("subhover"); //On hover over, add class "subhover"
}, function(){ //On Hover Out
jQuery(this).removeClass("subhover"); //On hover out, remove class "subhover"
});
@vilaon
Copy link

vilaon commented Jan 3, 2018

how can i use it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment