checkbox 全选/全不选
<th >
<input id="selectAll" type="checkbox">
</th>
省略中间代码.....
<td>
<input type="checkbox" name="uniqueCode">
</td>
//js代码
$(function() {
// 获得上面的复选框
var $selectAll = $("#selectAll");
// alert($selectAll.prop("checked"));
$selectAll.click(function() {
// alert($selectAll.prop("checked"));
if ($selectAll.prop("checked") == true) {
// 上面的复选框已被选中
$(":checkbox[name='uniqueCode']").prop("checked", true);
} else {
// 上面的复选框没被选中
$(":checkbox[name='uniqueCode']").prop("checked", false);
}
});
});
获取 checkbox value数组
var chk_value =[];
$('input[name="uniqueCode"]:checked').each(function(){
chk_value.push($(this).val());
});