I am trying to slide down a sub menu when hovering over a#about and keep the sub menu visible until hovering over another option.
I also want to hide the sub menu if not hovering over a#about or nav#about. Help please.
$(document).ready(function () {
$('a#about').hover(function(){
$('nav#about').slideDown();
});
$('nav#about').hover(function(){
$('nav#about').slideDown();
});
$('a#home').hover(function(){
$('nav#about').slideUp();
});
$('a#products').hover(function(){
$('nav#about').slideUp();
});
$('a#contact').hover(function(){
$('nav#about').slideUp();
});
});
=========================================
edited to include the html
<nav id="main" class="left">
<a id="home" class="left active">Home</a>
<a id="about" class="left" href="#">About</a>
<a id="products" class="left" href="#">Products</a>
<a id="contact" class="left" href="#">Contact</a>
</nav>
<nav id="about" class="left">
<a href="#"></a><br />
<a href="#"></a><br />
<a href="#"></a><br />
<a href="#"></a><br />
<a href="#"></a><br />
</nav>
Assuming all navigation
divshave class attribute ofnavand the navigation links are wrapped in adivornavtag like this:you can do something like this:
It basically binds to
hoverevent ofanchorsand elements ofnavclass and hides all thenavdivs except the current div (the hovered one) and slidesDown the hovered div if it’s not visible, also when navigation divs or anchors are not hovered, it slides up the divs after 1 second usingsetTimeout().See the Demo.