开发者

How do I add a exception to the document for a menu system, using JQuery?

开发者 https://www.devze.com 2023-01-14 05:06 出处:网络
How do I add exceptions to the document? For example within DIV(.rtmenu) I want to exclude links with the class (a.menu-arrow). So if I click/mousedown on (a.menu-arrow)...the DIV(.rtmenu) doesn\'t f

How do I add exceptions to the document?

For example within DIV(.rtmenu) I want to exclude links with the class (a.menu-arrow). So if I click/mousedown on (a.menu-arrow)...the DIV(.rtmenu) doesn't fadeOut?

$('.rtmenu').live('click', function(e) { e.stopImmediatePropagation(); });
$(d开发者_运维百科ocument).mousedown(function() { $('.rtmenu').fadeOut(200); });

Any help is greatly appreciated. Thanks


You can add a stop propgation to the menu links as well, like this:

$('.rtmenu').live('click', function(e) { e.stopImmediatePropagation(); });
$('.a-menu-arrow').live('mousedown', function(e) { e.stopImmediatePropagation(); });
$(document).mousedown(function() { $('.rtmenu').fadeOut(200); });


You could try the .not() function:

$('.rtmenu').not('a.menu-arrow').live(...


http://api.jquery.com/not-selector/ You'll need to use :not

0

精彩评论

暂无评论...
验证码 换一张
取 消