表行单击事件和复选框

时间:2015-04-01 12:30:08

标签: jquery

我有一个附加到表格行的点击事件,在列中我有复选框。

<table>
    <tbody>
        <tr class='shop_order_single_table'>
            <td><input type='checkbox' /></td>
            <td><input type='checkbox' /></td>
            <td><input type='checkbox' /></td>
        </tr>
    </tbody>
</table>

当我单击该复选框时,该行的click事件仍会执行。

这是我的代码:

     $(".shop_order_single_table").on("click",function() {
   //click event executes
                });

单击复选框时如何才能执行表格行的点击事件?

1 个答案:

答案 0 :(得分:1)

$(".shop_order_single_table input").on("click", function(e) { 
   e.stopPropagation();
});   

$(".shop_order_single_table").on("click", function(e) { 
   // Your code
});
相关问题