$(function(){
//全选
$("#quanxuan").click(function(){
$(":checkbox").each(function(){
$(this).attr(“checked”,true);
})
})
//全不选
$("#quanbuxuan").click(function(){
$(":checkbox").each(function(){
$(this).attr(“checked”,false);
})
})
//反选
$("#fanxuan").click(function(){
$(":checkbox").map(function(i,n){
n.checked =! n.checked;
})
})
});
<input type="button" value="全选" name="quanxuan" id="quanxuan">
<input type="button" value="反选" name="fanxuan" id="fanxuan">
<input type="button" value="全不选" name="quanbuxuan" id="quanbuxuan">
#在定义一个复选框,并获取id