<!--html代码:-->
<tr>
<th width='30'><input type='checkbox' id='selectall' onclick='getChanges();' /></th>
</tr>
<tr>
<td><input type='checkbox' id=" a" name='cks' value=" a" /></td>
<td><input type='checkbox' id=" b" name='cks' value=" b" /></td>
<td><input type='checkbox' id=" c" name='cks' value=" c" /></td>
<td><input type='checkbox' id=" d" name='cks' value=" d" /></td>
<td><input type='checkbox' id=" e" name='cks' value=" e" /></td>
</tr>
//js 代码:
function getChanges() {
var isChecked = $("#selectall").attr("checked"); //判断一个复选框是否被选中
if (isChecked) {
$("[name='cks']").attr("checked", 'true'); //全选
}
else {
$("[name='cks']").removeAttr("checked"); //取消全选
}
}