// 使用attr只能执行一次
function selectAll(o) {
if (o.checked) {
$(".chkCss").attr("checked", true);
} else {
$(".chkCss").attr("checked", false);
}
}
// 使用prop则完美实现全选和反选
$('#all').on('click', function () {
if (this.checked) {
//$("input[name='check']").attr('checked', true);
$("input[name='check']").prop('checked', true);
} else {
$("input[name='check']").prop('checked', false);
}
});
网友评论