标签:
checkbox中有.checked的写法,判断当前是否是选中状态,不过这种是针对[object HTMLInputElement]这种类型的,而对于[object Object]这种类型是不能使用的
$("#checkall").checked会出现undefined
$("#checkall").click(function () {
if ($("#checkall").attr("checked")) {//jquery对象进行判定选中状态,还有一种是prop
$("input:checkbox[name=‘ids‘]").each(function () {
//这里的this对象的类型和$()->[object Object]不同,是[object HTMLInputElement]类型的
if (!this.checked) {//是this,不是$(this)
this.checked = true;
}
});
} else {
$("input:checkbox[name=‘ids‘]").each(function () {
if (this.checked) {
this.checked = false;
}
});
}
})
标签:
原文地址:http://www.cnblogs.com/danlis/p/5948028.html