Implement the CheckBox check box in table, and determine if checked is selected, JS operation Checkedbox selected

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.