【发布时间】:2012-10-05 06:14:39
【问题描述】:
我使用了两个 div 并为它们的内部元素定义了点击事件 在 jquery 1.7.2 中使用委托。第一次点击事件工作正常 预期的,第二个不起作用。
$("#first").delegate(".ask div:first","click",function(e){
alert("hi");
});
$("#second").delegate(".ask div:first","click",function(e){
alert("hello");
});
HTML 标记:
<div id="first" >
<div class="ask">
<div> hi </div>
<div> disabled </div>
</div>
</div>
<div id="second" >
<div class="ask">
<div> hello </div>
<div> disabled </div>
</div>
http://jsfiddle.net/YjK3N/3/ 但在 jquery 较低版本中,上述代码按预期工作正常。
【问题讨论】:
标签: jquery html jquery-delegate