如何通过内联onclick属性停止事件传播? [英] How to stop event propagation with inline onclick attribute?
本文介绍了如何通过内联onclick属性停止事件传播?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
考虑以下内容:
<div onclick="alert('you clicked the header')" class="header">
<span onclick="alert('you clicked inside the header');">something inside the header</span>
</div>
如何让用户点击跨度,不会触发 div
的点击事件?
How can I make it so that when the user clicks the span, it does not fire the div
's click event?
推荐答案
编辑:
对于IE: window.event.cancelBubble = true
这篇关于如何通过内联onclick属性停止事件传播?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文