HTML:
<ul class="dropdown">
<li><a href="#">Item 1</a></li>
<li>
<a href="#">Item 2</a>
<div class="submenu">something</div>
</li>
</ul>
jQuery:
$j("ul.dropdown li").hover(function () {
$j(this).addClass("hover");
$j('div.submenu', this).css('visibility', 'visible');
}, function () {
$j(this).removeClass("hover");
$j('div.submenu', this).css('visibility', 'hidden');
});
... the menu works fine, but when the div.submenu
is shown and I move the cursor to it, the link that opened this submenu loses its 'hover' class, how do I maintain hover state on both the link and the submenu when they're open?
I tried this, but its not working:
$j("ul.dropdown li").hover(function () {
$j(this).addClass("hover");
$j('div.submenu', this).css('visibility', 'visible').hover(function () {
$j(this).prev('a').addClass('hover');
}, function () {
$j(this).prev('a').removeClass('hover');
});
}, function () {
$j(this).removeClass("hover");
$j('div.submenu', this).css('visibility', 'hidden');
});
Thanks!