如何禁用父元素的onclick元素 [英] How to make disable onclick element of parent element

查看:106
本文介绍了如何禁用父元素的onclick元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有tr的表格,如

i had a table with tr's like

<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>

如何实现?专家plz帮助

How to achieve this? Experts plz help

推荐答案

您需要停止 event bubbling

You need to stop event bubbling.

/ strong>

Note

将其 unobtrusive

<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();
    });
});

这篇关于如何禁用父元素的onclick元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆