<scripttype="text/javascript">

$(function(){

$("input[name='hobby']").click(function(){

$("input[name='hobby']:checked").length==$("input[name='hobby']").length?$("#checkAll").attr("checked",true):$("#checkAll").attr("checked",false);

});

$("#checkAll").click(function(){

$("input[name='hobby']").attr("checked",this.checked);

});

$("#checkReverse").click(function(){

vararr=jQuery("input[name='hobby']");

for(vari=0;i<arr.length;i++){

arr[i].checked=!arr[i].checked;

}

});

});

</script>

<formaction="test.htm"method="post"id="form"name="form">

<inputid="checkAll"type="checkbox"/>全选/<inputid="checkReverse"type="checkbox"/>反选

<br/>

<inputtype="checkbox"name="hobby"/>

<inputtype="checkbox"name="hobby"/>

<inputtype="checkbox"name="hobby"/>

<inputtype="checkbox"name="hobby"/>

<inputtype="checkbox"name="hobby"/>

</form>