jQuery中on绑定事件后引发的事件冒泡问题如何解决

2020-05-29 07:17:45易采站长站整理

console.log(e.target.tagName);
console.log("tr1被点击了");
})
$("#aa").on("click","#table1",function(e){
console.log(e.target.tagName);
console.log("table1被点击了");
})
});
</script>
</head>
<body id="aa">
<table onclick="alert('这是table')">
<tr onclick="alert('这是tr')">
<td onclick="alert('这是td')">
<p onclick="alert('这是p')">段落</p>
</td>
</tr>
</table>
<table id="table1">
<tr id="tr1">
<td id="td1">
<p id="p1">你好</p>
</td>
</tr>
</table>
</body>
</html>

以上所述是小编给大家介绍的jQuery中on绑定事件后引发的事件冒泡问题及解决办法,希望能够帮助到大家!