I'm trying a simple jQuery menu with submenus showing on hover, if I use "show" and "hide" function, everything Works just fine, but if I bind a function like slideDown or Up, it will repeat the function until the cursor goes out of the binded LI object.
$('.myMenu > li').on('mouseover', openSM);
$('.myMenu > li').on('mouseout', closeSM);
function openSM() {
$(this).find('ul').show();
};
function closeSM() {
$(this).find('ul').hide();
};
When I set the show()
and hide()
to slideDown()
and slideUp()
, it basically repeats on all submenus on it.
<li><a href="#">menu item</a>
<ul>
<li><a href="#">sub menu item 1</a></li>
<li><a href="#">sub menu item 2</a></li>
<li><a href="#">sub menu item 3</a></li>
<li><a href="#">sub menu item 4</a></li>
</ul>
</li>
On every submenu item it will repeat the function... It means it will slideup and down repetitively. Well, what I want to do is to set it to just use the function when it leaves the LI object, not when it's hovering the submenus...
I replace bind with on, but it still don't work with slideDown and Up functions... Any help?