Hello! I installed a jQuery menu on a website that I'm building. Can anyone tell me how to modify this code so that it will close back up when not being hovered on? Currently, once you open it, it does not completely shut up. Here is the website I'm designing: http://corporationmerger.net Here is the page I found the script at(I'm using the first Standard Accordian version): http://www.i-marco.nl/weblog/jquery-accordion-3/ Here is the menu code: jQuery.fn.initMenu = function() { return this.each(function(){ var theMenu = $(this).get(0); $('.acitem', this).hide(); $('li.expand > .acitem', this).show(); $('li.expand > .acitem', this).prev().addClass('active'); $('li a', this).hover( function(e) { e.stopImmediatePropagation(); var theElement = $(this).next(); var parent = this.parentNode.parentNode; if($(parent).hasClass('noaccordion')) { if(theElement[0] === undefined) { window.location.href = this.href; } $(theElement).slideToggle('normal', function() { if ($(this).is(':visible')) { $(this).prev().addClass('active'); } else { $(this).prev().removeClass('active'); } }); return false; } else { if(theElement.hasClass('acitem') && theElement.is(':visible')) { if($(parent).hasClass('collapsible')) { $('.acitem:visible', parent).first().slideUp('normal', function() { $(this).prev().removeClass('active'); } ); return false; } return false; } if(theElement.hasClass('acitem') && !theElement.is(':visible')) { $('.acitem:visible', parent).first().slideUp('normal', function() { $(this).prev().removeClass('active'); }); theElement.slideDown('normal', function() { $(this).prev().addClass('active'); }); return false; } } } ); }); }; $(document).ready(function() {$('.menu').initMenu();}); Code (markup):
There is also a much simpler version available. Whichever one you choose, add another function inside the hover code for when the mouse leaves: function initMenu() { $('#menu ul').hide(); $('#menu li a').hover( function() { $(this).next().slideToggle('normal'); }, function() { $(this).next().slideToggle('normal'); } ); } $(document).ready(function() {initMenu();}); Code (markup):
I can not understand why people are building websites and do not have a clue about what they are doing. Ok, I am taking jQuery plugins too. But I know how to deal with them.