这几天遇见js方法事件冒泡的问题
<tr onclick=a>
<td onclick=b>
</td>
<td>
</td>
</tr>
在tr中有多个td,tr与其中一个td有触发事件,这时候点击td就会同时触发两个事件。
解决办法:
在b方法中加入
var e = window.event; // Get the window event
e.cancelBubble = true; // IE Stop propagation
if (e.stopPropagation) {
e.stopPropagation(); // Other Broswers
}
原文:https://www.cnblogs.com/lansetuerqi/p/12849575.html