I am working on a Mega Menu and using a unordered list to trigger a event to show the Mega Menu. This is the HTML code for Nav Bar:
<div class="alpha omega grid_15" id="topNavLink">
<ul id="navRollOver">
<li><a href="#" title="SOCCER" target="_self" >SOCCER</a></li>
<li><a href="#" title="TENNIS" target="_self" >TENNIS</a></li>
<li><a href="#" title="BASEBALL" target="_self" >BASEBALL</a></li>
<li><a href="#" title="BASKETBALL" target="_self" >BASKETBALL</a></li>
<li><a href="#" title="FOOTBALL" target="_self" >FOOTBALL</a></li>
<li><a href="#" title="GOLF" target="_self" >GOLF</a></li>
<li><a href="#" title="RUGBY" target="_self" >RUGBY</a></li>
<li><a href="#" title="HOCKEY" target="_self" >HOCKEY</a></li>
</ul>
</div>
I am calling a div with class subNavContainer
, css status is display: none
;
This is what I want to do... I am planning to get the Array of all the li
and target > a
and listen to the mouse enter event to trigger the mega menu to slideDown
.
I need help with Iterating through the li
checking if it has a
and based on the mouseenter
on a
I want to trigger an event to display the megaMenu
using slideDown
, and when the mouse moves to the next()
a
, I want to trigger the slideUp
event.
Similarly if the mouseenters the subNavContainer
it should remain on screen and when the mouseleaves the subNavContainer
or if there is no movement on the screen the subNavContainer
should slideUp
.
To select all the links that are children of the
li
elements your selector can look like this:To then bind to the
mouseenter
event for those elements:Then to
slideUp
the menu after the cursor leaves the link elements: