<div id="parent">
<div id="child">
</div>
</div>
let parentDiv=document.getElementById("parent");
let childDiv=document.getElementById("child");
parentDiv.onlick=function(ev){
//判断是否是parentDOM对象触发的事件
if(ev.target!=this) return false;
console.log("1111")
}
JS点击父元素时子元素不触发事件
猜你喜欢
转载自blog.csdn.net/qq_35953966/article/details/107064692
今日推荐
周排行