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

浙公网安备 33010602011771号