$(function() {
$("#CheckAll").click(function() {
var flag = $(this).attr("checked");
$("[name=subBox]:checkbox").each(function() {
$(this).attr("checked", flag);
})
})
}) 为什么只能全选,就不能反选呢?
以上代码。
$("#CheckAll").click(function() {
var flag = $(this).attr("checked");
$("[name=subBox]:checkbox").each(function() {
$(this).attr("checked", flag);
})
})
}) 为什么只能全选,就不能反选呢?
以上代码。
$("#CheckAll").click(function() {
$("[name=subBox]:checkbox").attr("checked", $(this).attr("checked"));
}) ;
}
如果是cheched是不是要去除
$(function() {
$("#CheckAll").click(function() {
$("[name=subBox]:checkbox").each(function(){
$(this).attr("checked", !$(this).attr("checked"));// 取反就行了
});
}) ;
}
1.6得用.prop()