$(‘input[name="teams"]:checked‘).size()
1 // 全选 2 $("#quanteam").bind("click", function () { 3 $("[name = teams]:checkbox").attr("checked", true); 4 }); 5 // 全不选 6 $("#quanteam1").bind("click", function () { 7 $("[name = teams]:checkbox").attr("checked", false); 8 });
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"; } }
jQuery 获取 多个 复选框 和 javascript 对比
时间: 2024-11-29 09:15:24