Mar*_*ndy 0 javascript jquery html-table
<table>
<tr>
<td><input type="checkbox"></td><td>aa</td><td>ss</td>
</tr>
<tr>
<td><input type="checkbox"></td><td>aa</td><td>ss</td>
</tr>
<tr>
<td><input type="checkbox"></td><td>aa</td><td>ss</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
现场: http ://jsfiddle.net/6U5WH/
如果我点击带有当前复选框的TR,如何检查和取消选中复选框的最佳方法是什么?只能使用HTML(标签?)?如果不是,我想使用jQuery.
// when the row is clicked toggle the checked property
$('tr').click(function() {
var $cb = $(this).find(':checkbox');
$cb.prop('checked',!$cb.prop('checked'));
});
// prevent a click on the actual checkbox from bubbling to the row
$('tr :checkbox').click( function(e) {
e.stopPropagation();
});
Run Code Online (Sandbox Code Playgroud)
更新小提琴:http://jsfiddle.net/6U5WH/1/