可能重复:
jquery stop child triggering parent event化妆开销div标签是不导电的劣质格
我有2 div标签,父母和孩子,我想在点击父格 - 警报()一些。问题在于:在点击儿童div时,alert()也发生了,我想调用alert只需要点击父div标签区域,请告诉如何做到这一点? 这是我的HTML代码
<div id="out_div" style="width: 200px; height: 200px; background-color: #090; position: absolute; z-index: 1">
<div id="inner_div" style="width: 100px; height: 100px; background-color: #009; position: absolute; z-index: 2; margin-left: 50px; margin-top: 50px;">
</div>
</div>
和JS代码:
$(document).ready(function() {
$("#out_div").on("click", function() {
alert("asd");
});
});
可能的[复制](HTTP:/ /stackoverflow.com/questions/2364629/jquery-stop-child-triggering-parent-event)http:// sta ckoverflow.com/questions/2364629/jquery-stop-child-triggering-parent-event –
谢谢你的回答。 @Tarek Fadel – RIKI