Copy codeThe Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Script language = "javascript" src = "../css02/js/jquery-1.6.1.js"> </script>
<Script>
$ (Document). ready (function (){
$ ("# SelectAll"). click (function (){
// You can also directly use this, native js statement here
If ($ (this) [0]. checked ){
$ ('[Name = items]: checkbox'). attr ("checked", true );
} Else {
$ ('[Name = items]: checkbox'). attr ("checked", false );
}
});
$ ("# XOR"). click (function (){
$ ("[Name = items]: checkbox"). each (function (){
This. checked =! This. checked;
});
});
});
</Script>
<Title> Untitled Document </title>
</Head>
<Body>
<Input type = "checkbox" name = "items" value = ""/> football
<Input type = "checkbox" name = "items" value = ""/> football
<Input type = "checkbox" name = "items" value = ""/> football
<Input type = "checkbox" name = "items" value = ""/> football
<Input type = "checkbox" id = "selectAll" value = "select all/do not select"/> select all/all
<Input type = "button" id = "XOR" value = "invert"/>
</Body>
</Html>