is the implementation effect.
Paste the following code
The first line of the table is the code in <th>, and the onclick event is a full or no-select effect.
< th > < ID= "Allboxs" onclick= "Allcheck ()" type= "checkbox" /></th>
The code in TD
< TD > < input name = "Boxs" type = "checkbox" /> </ TD >
JS to achieve the full selection, all the effect of the selection
functionAllcheck () {varnn = $ ("#allboxs"). Is (": Checked"); Determines if the checkbox in th is selected, if it is selected, NN is true, and vice versa is Falseif(NN = =true) { varNamebox = $ ("input[name^= ' Boxs ')"); Gets all input with the name value of Boxs for(i = 0; i < namebox.length; i++) {namebox[i].checked=true; JS operation check checkbox}}if(NN = =false) { varNamebox = $ ("input[name^= ' Boxs ')"); for(i = 0; i < namebox.length; i++) {namebox[i].checked=false; } } }
The above code is worth mentioning, to get the value of the checkbox or something else, it is recommended to use the Name property value operation, because the id attribute is unique in each page, and the Name property can take all the same property value.
Implement the CheckBox check box in table, and determine if checked is selected, JS operation Checkedbox selected