JQuery点击行tr实现checkBox选中与未选中切换

点击table中的行时checkbox选中,再次点击取消。如何将tr作为模板插入的话可以在每一行tr注册点击事件

 <tr onclick=" $($(this).children()[0]).children()[0].checked = ! $($(this).children()[0]).children()[0].checked" >
         <td style="text-align: center;  10%;">
                <input  name="chercked"  type="checkbox"/>
            </td>
            <td  style="45%; text-align: center;" >
            </td>
              <td  style="45%;text-align: center;">
            </td>
        </tr>

当然也可以

$("#tables tbody tr").click(function (e) {
         var checkboxs = $($(this).children()[0]).children()[0]
         checkboxs .checked = !checkboxs .checked
})
原文地址:https://www.cnblogs.com/wxblogs/p/14756369.html