如何为受event.stopPropagation()影响的容器内的元素创建某种形式的异常,例如
<ul class="test">
<li><a href="#" class="test1"></a></li>
</ul>
<script type="test/javscript">
$(".test").click(function(e){
e.stopPropagation();
});
$(".test1").click(function(e){
some statements...
});
</script>
我希望.test1在点击时触发一个事件。
答案 0 :(得分:0)
事件冒出来,stopPropagation
在你的情况下会通过点击处理停止<ul class="test">
的任何父元素。
但是您可能有兴趣检查传播是否已停止,请在事件处理中使用event.isPropagationStopped
。