<div class="iteye-blog-content-contain" style="font-size: 14px">
$('#user_list tbody').on( 'click', ' td', function () {
if($(this).index()==0){
if($("#user_list input:not(:checkbox:checked)").length<1){
$('#mainCheckbox1').prop('checked', true);
}else{
$("#mainCheckbox1").removeAttr("checked");
}
}
});
function checkAll() {
// 当点击后复选框如果变为选中状态所执行的逻辑
if ($(this).prop('checked') == true) {
// 将head和foot区域中的两个复选框置为选中状态
$('#user_list thead :checkbox').prop('checked', true);
// 将表格body区域中的所有复选框置为选中状态
$('#user_list tbody :checkbox').each(function(index, element) {
$(element).prop('checked', true);
});
} else {
// 将表格head和foot区域中的两个复选框置为没有选中的状态
$('#user_list thead :checkbox').prop('checked', false);
// 将表格body区域中的两个复选框置为没有选中的状态
$('#user_list tbody :checkbox').each(function(index, element) {
$(element).prop('checked', false);
});
}
}
</div>
$('#user_list tbody').on( 'click', ' td', function () {
if($(this).index()==0){
if($("#user_list input:not(:checkbox:checked)").length<1){
$('#mainCheckbox1').prop('checked', true);
}else{
$("#mainCheckbox1").removeAttr("checked");
}
}
});
function checkAll() {
// 当点击后复选框如果变为选中状态所执行的逻辑
if ($(this).prop('checked') == true) {
// 将head和foot区域中的两个复选框置为选中状态
$('#user_list thead :checkbox').prop('checked', true);
// 将表格body区域中的所有复选框置为选中状态
$('#user_list tbody :checkbox').each(function(index, element) {
$(element).prop('checked', true);
});
} else {
// 将表格head和foot区域中的两个复选框置为没有选中的状态
$('#user_list thead :checkbox').prop('checked', false);
// 将表格body区域中的两个复选框置为没有选中的状态
$('#user_list tbody :checkbox').each(function(index, element) {
$(element).prop('checked', false);
});
}
}
</div>