I have this html menu. Some menu items have a submenu.
<ul class="menu uppercase">
<li class="mitem">Level 1 Menu Item
<ul class="submenu">
<li class="smitem">Level 2 Menu Item</li>
<li class="smitem">Level 2 Menu Item</li>
<li class="smitem">Level 2 Menu Item</li>
<li class="smitem">Level 2 Menu Item</li>
<li class="smitem">Level 2 Menu Item</li>
</ul>
</li>
<li class="mitem">Level 1 Menu Item
<ul class="submenu">
<li class="smitem">Name of Collection</li>
<li class="smitem">Level 2 Menu Item</li>
<li class="smitem">Level 2 Menu Item</li>
<li class="smitem">Level 2 Menu Item</li>
<li class="smitem">Level 2 Menu Item</li>
</ul>
</li>
<li class="mitem">Level 1 Menu Item</li>
<li class="mitem">Level 1 Menu Item</li>
<li class="mitem">Level 1 Menu Item</li>
The Jquery Looks like this.
$("li.mitem").click(function(){//when menu item is clicked
$("ul.submenu").slideUp();//hide all sub menus
$("li.mitem").css('margin-bottom','0px').css('border-left','none');//reset margin bottom and left border
$(this).css('border-left','1px solid #E0E0E0').css('padding-left','9px');//add border and padding to this menu item
$(this).children("ul.submenu").slideDown();//show menu items child sub menu
$(this).children().children("li.smitem:first").css('padding-top','18px');//add padding to first sub menu item
if($(this).children().length>0){
$(this).css('margin-bottom','18px');
}
});
So basically, when you click on a level 1 menu item it displays the submenu for that menu item by sliding it down. when you click on the next level 1 menu item if slides up the current sub menu and slides down the next sub menu.
However.... and the problem is... When you click on a level 2 menu item it slides up the sub menu and then back down again.
I believe this is happening because the sub menu is within the li of the level 1 menu.
How can i stop this? Its an unexpected behaviour.