$(function(){
$("#quanxuan").click(function(){
$(":checkbox").each(function(){
$(this).attr(“checked”,true);
})
})
$("#quanbuxuan").click(function(){
$(":checkbox").each(function(){
$(this).attr(“checked”,false);
})
})
})
//反选
function btn1() {
$(":input:checkbox").map(function (i,n) {
n.checked=!n.checked;
})
}
//补充map方法
$(function () {
//全选
$("#quanxuan").click(function () {
$(":checkbox").map(function (i,n) {
n.checked = true;
})
})
//全不选
$("#quanbuxuan").click(function () {
$(":checkbox").map(function (i,n) {
n.checked = false;
})
})
//反选
$("#fanxuan").click(function () {
$(":checkbox").map(function (i,n) {
n.checked = !n.checked;
})
})
<body>
<input type="button" id="quanxuan" value="全选">
<input type="button" id="quanbuxuan" value="全不选">
<input type="button" id="fanxuan" value="反选" "btn1()">
<c:forEach items="
l
i
s
t
"
v
a
r
=
"
l
"
>
<
t
r
>
<
t
d
>
<
i
n
p
u
t
t
y
p
e
=
"
c
h
e
c
k
b
o
x
"
v
a
l
u
e
=
"
{list }" var="l"> <tr> <td><input type="checkbox" value="
list"var="l"><tr><td><inputtype="checkbox"value="{l.bid }">
</c:forEach>