Jquery code
Copy codeThe Code is as follows:
<Script type = "text/javascript" src = "jquery-1.4.2.min.js"> </script>
<Script type = "text/javascript">
Function Checked () {// define the function checked
$ (". Chk"). each (function () {// traverse the check box label whose class is chk in html
If ($ (this). attr ("checked") = true) {// if the current check box's checked attribute is true
$ (This). attr ("checked", false); // change this attribute to false
}
Else {// If the checked attribute of the current check box is false
$ (This). attr ("checked", true); // change this attribute to true.
}
});
If ($ ("# lbl" ).html () = "select all") {// modify the label text to "invert"
$ ("# Lbl" ).html (" ");
}
Else if ($ ("# lbl" ).html () = "") {// modify the label text to "select all"
$ ("# Lbl" ).html ("select all ");
}
}
$ (Document). ready (function () {// Add a click event for the label to execute the function checked
$ ("# Lbl"). bind ("click", Checked );
})
</Script>
Html code
Copy codeThe Code is as follows:
<Label id = "lbl"> select all </label>
<Table>
<Tr>
<Td>
<Input type = "checkbox" class = "chk"/>
</Td>
</Tr>
<Tr>
<Td>
<Input type = "checkbox" class = "chk"/>
</Td>
</Tr>
<Tr>
<Td>
<Input type = "checkbox" class = "chk"/>
</Td>
</Tr>
<Tr>
<Td>
<Input type = "checkbox" class = "chk"/>
</Td>
</Tr>
<Tr>
<Td>
<Input type = "checkbox" class = "chk"/>
</Td>
</Tr>
</Table>
O (TIPS _ Tips) O make a little progress every day O (TIPS _ Tips) O this BLOG is for individuals to record learning notes. If you have any mistakes, please note!