Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jquimera/5e542ca58bfaa26eb0870fa8cd1a36c1 to your computer and use it in GitHub Desktop.
Save jquimera/5e542ca58bfaa26eb0870fa8cd1a36c1 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"
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment