我有一张有 tr 的 table
<tr onclick="doprocess1()">
<td>Some data</td>
<td>Some data</td>
<td><button onclick="doprocess2()"</td> <!--I want to disable the clickevent of the <tr> here -->
</tr>
如何实现?
最佳答案
你需要停止event bubbling .
注意
<tr id="tr1">
<td>Some data</td>
<td>Some data</td>
<td><button id="bt1">Click</button></td> <!--I want to disable the clickevent of the <tr> here -->
</tr>
$(function(){
$("#tr1").click(function(){
});
$("#bt1").click(function(e){
e.stopPropagation();
});
});
关于javascript - 如何禁用父元素的onclick元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4666013/