/ Published in: jQuery
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$(function(){ var menu = $("#nav"); menu.find("ul.sf-menu") .superfish({ delay: 0, speed: 'fast', autoArrows: false, dropShadows: false, onHide: function(){ if (this.parent().is('.sfPersist')) { this.show().css('visibility','visible').parent().addClass('sfHover'); } } }) .find('li > ul > li').click(function(){ // hide previously persistent children (LOL that just sounds wrong) menu.find('.sfPersist') .removeClass('sfPersist sfHover') .find('> ul').hide().css('visibility','hidden'); // add children that should be persistent if ($(this).is('.sfSelected')) { // if previously selected, keep hidden menu.find('li.sfSelected').removeClass('sfSelected'); } else { // Hide other selected classes menu.find('li.sfSelected').removeClass('sfSelected'); // if newly selected, then show $(this) .addClass('sfSelected') // remember which one is selected .parent() .show().css('visibility','visible') .parent().addClass('sfHover sfPersist'); } }); });