1.Jquery全选与反选(注册事件) $("#chkAll").click(function(){ $("#reveChk").attr("checked",false); $(":checkbox:not(this,#reveChk)").attr("checked",!!$(this).attr("checked")); }); $("#reveChk").click(function(){ $(":checkbox:not(#chkAll,#reveChk)").each(function(){ $(this).attr("checked",!!!$(this).attr("checked")); }); }); 2.Jquery全选与反选(表单事件) //反选 function reverse(){ //遗留了一个bug,看不下去就自己完善. $("[name='hobbies']").each(function(){ //$(this).attr("checked",!!!$(this).attr("checked")); var oldchecked=!!$(this).attr("checked");//原始的选择状态 $(this).attr("checked",!oldchecked); }); } //全选全不选 function selClick(){ //var checked=!!$("#chkAll").attr("checked");//checked属性的值 $("[name='hobbies']").attr("checked",!!$("#chkAll").attr("checked")); }