Dismiss Menu when Focus is lost, not on mouseout. jQuery
Posted
by Stacey
on Stack Overflow
See other posts from Stack Overflow
or by Stacey
Published on 2010-04-25T20:21:33Z
Indexed on
2010/04/25
20:23 UTC
Read the original article
Hit count: 216
jQuery
I have jQuery that drops a menu down when its parent is clicked on, and dismisses it when they hover away from the menu. I am wanting to change the behavior so that it only dismisses if they click somewhere else on the page, or a different menu. Is this possible?
jQuery.fn.dropdown = function () {
return this.each(function () {
$('.ui-dropdown-list > li > a').click(function () {
$(this).addClass("ui-dropdown-hover");
});
$("ul.ui-dropdown-list > li > a").click(function () {
$(this).parent().find("ul").show();
$(this).parent().hover(function () {
}, function () {
$(this).parent().find("ul").hide();
$(this).find('> a').removeClass("ui-dropdown-hover");
});
});
});
};
© Stack Overflow or respective owner