我有一个表的设置是这样的:检查所有的复选框中的jQuery
<table>
<thead>
<th>
<input type="checkbox" class="check-all" />
</th>
<th>
Title
</th>
</thead>
<tbody>
<tr>
<td><input type="checkbox" /></td>
<td>Name</td>
</tr>
<tr>
<td><input type="checkbox" /></td>
<td>Name 2</td>
</tr>
</tbody>
</table>
我想拥有它,所以当与类的检查,所有的'标题中的复选框被选中,它会检查所有下面的复选框。
这是我有什么,但似乎并没有工作
$('.check-all').click(
function(){
$(this).parent().parent().parent().find("input[type='checkbox']").attr('checked', $(this).is(':checked'));
}
)
任何想法?谢谢!