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; width: 10%;">
                <input  name="chercked"  type="checkBox"/>
            </td>
            <td  style="width:45%; text-align: center;" >
            </td>
              <td  style="width:45%;text-align: center;">
            </td>
        </tr>

当然也可以

$("#tables tbody tr").click(function (e) {
         var checkBoxs = $($(this).children()[0]).children()[0]
         checkBoxs .checked = !checkBoxs .checked
})

 

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...