添加 Not of jquery 相反的最好方法是什么?
<div class="line-item">
<div class="thumb">
Image goes here
</div>
<div class="title">
Title goes here
</div>
<div class="destroy">
Destroy Button goes here
</div>
这是 Java 脚本
$('div.line-item').delegate('div:not(".destroy")', 'click', function() {
alert('hi');
})
我想要的是在具有 .destroy 类的 div 上应用“点击”
这是工作演示: http://jsfiddle.net/trVKF/110/
最佳答案
使用更新版本的 jQuery 并执行以下操作:
$('div.line-item').on('click', '.destroy', function() {
// ^^ static parent | ^^ event | ^^ dynamic element bound to handler
alert('hi');
});
关于javascript - 通过委托(delegate)在jquery中的选定div上应用点击功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20496929/