//增加两个插件方法。
jQuery.fn.extend({
check: function() {
returnthis.each(function() {
this.checked = true;
});
},
uncheck: function() {
returnthis.each(function() {
this.checked = false;
});
}
});
//复选框的全选与反选
$("#qcheckBox").click(function() {
if($("#qcheckBox").attr("checked")) {
$("#div2 input[type = checkbox]").check(); //获取checkbox的方式一
} else {
$("#div2 input:checkbox").uncheck(); //获取checkbox的方式二
}
});