$('input[name="teams"]:checked').size()
// 全选
$("#quanteam").bind("click", function () {
$("[name = teams]:checkbox").attr("checked", true);
});
// 全不选
$("#quanteam1").bind("click", function () {
$("[name = teams]:checkbox").attr("checked", false);
});
JS 写法
<input type="checkbox" name="" id="quanteam" onClick="this.value=check(this.form.teams)"/> 全选
var checkflag = "false";
function check(field) {
if (checkflag == "false") {
for (i = 0; i < field.length; i++) {
field[i].checked = true;}
checkflag = "true";
}else {
for (i = 0; i < field.length; i++) {
field[i].checked = false; }
checkflag = "false";
}
}