html 点击子元素事件而不触发父元素的点击事件

阻止冒泡事件即可

 

//jquery
$("#btn").click(function(event){
    event.stopPropagation();//阻止事件冒泡即可
});

//js
document.getElementById("btn").onclick=function(event){
    event.stopPropagation();//阻止事件冒泡即可
}
posted @ 2019-12-24 15:16  _DC  阅读(2100)  评论(0编辑  收藏  举报