【发布时间】:2012-03-03 06:36:27
【问题描述】:
假设我想绑定下面的所有项目
#mainDiv .user
除了
#mainDiv #exception .user
我能想到
$('#mainDiv .user').bind('event',function(){
if($(this).parents('#exception').length>0){}else{
// do stuff;
}
});
或:
$('#mainDiv :not('#exception').find('.user').bind('event',function(){
if($(this).parents('#exception').length>0){}else{
// do stuff;
}
});
有什么更好的?
【问题讨论】:
标签: jquery events css-selectors custom-exceptions