您现在的位置是:首页 > 电脑技术查询 > web开发

关于childNode和parentElement触发相同事件有关问题

编辑:chaxungu时间:2022-10-02 23:17:23分类:web开发

关于childNode和parentElement触发相同事件问题
<div onmousedown= "test1() "> <table> <tr onmousedown= "test2() "> <td> fffffff </td> </tr> </table>

怎样才能点击tr的时候不触发div的test1()



------解决方案--------------------
在 test2() 最后加上这句

window.event.cancelBubble = true;