dbi*_*ott 2 html javascript css jquery
UI 部分如下所示
我的垃圾桶在点击时工作正常,但那时我不需要在蓝色 div 上有点击事件。现在我在蓝色 div 上也有一个单击事件,当我单击垃圾桶时,我得到的是蓝色 div 对象而不是垃圾桶对象。我尝试了一些 z-index 技巧,但没有用。
任何帮助表示赞赏。
<td id="ea-13" class="activityTableCell">
<div style="width:90px; margin-left:0px" class="eventTimeSpan"></div>
<div id="NewActivityContainer-13" class="activityContainerExisting">
<div data-uid="57386445" class="label label-sm label-info newActivityClass point" style="width:59px; top:-1px; left:30px; z-index:4000" title="Mobile Game Party">
Mobile Game Party
<div data-isactivity="1" data-packageid="" data-elid="57386445" class="xRemove" style="left:46px;z-index:8000"><i class="fa fa-trash font-red" title="Remove"></i>
</div>
</div>
</div>
</td>
Run Code Online (Sandbox Code Playgroud)
点击代码:
$(document).on("click", ".newActivityClass", function(){
console.log(this);
...snip...
}
$(document).on("click", ".xRemove,.aRemove", function(){
...snip...
}
Run Code Online (Sandbox Code Playgroud)
你可以试试event.stopPropagation()
$(document).on("click", ".xRemove,.aRemove", function(event){
event.stopPropagation();
// code here
});
Run Code Online (Sandbox Code Playgroud)
来源: https: //api.jquery.com/event.stoppropagation/
| 归档时间: |
|
| 查看次数: |
3633 次 |
| 最近记录: |