我有一个标签......
<span id="Tab_1" class='Global_OFF'>
<span id="Tab_Name_1">Tab Name</span>
<span id="Delete_1" class="Tab_Delete">X</span>
</span>
我发生了两个jquery操作。一个是当我单击选项卡本身的类'Global_Off'时,另一个是当我单击删除按钮时,它是类'Tab_Delete'。不幸的是,当我单击类'Tab_Delete'时,它将触发类'Global_OFF'。有没有办法点击'Tab_Delete'而不用这种格式激活'Global_OFF'?
答案 0 :(得分:1)
在删除按钮点击事件上使用stopPropagation(),这会阻止事件冒泡到父span.Global_OFF
。
$('.Tab_Delete').click(function(e){
//Other stuff
e.stopPropagation();
});