JS control checkbox Get Select all Select All not select All selected is not selected All selection is selected

Source: Internet
Author: User
Tags sca

Click the Select All button event action    function SelectAll () {         var allcheckboxs=document.getelementsbyname ("ITo");         var select=document.getelementsbyname ("select");         if (select[0].checked) {//, each selected, select All button is selected for           (Var i=0;i<allcheckboxs.length;i++) {              allcheckboxs[i]. Checked = true;            }         } else{  //There is one not selected. Select All button without selecting for         (var i=0;i<allcheckboxs.length;i++) {             allcheckboxs[i].checked = false;}           }       }          $ (' Input[name=sca] '). Click (function () {var ckslength = $ (' Input[name=sca] '). Length;if (!$ (this) [0].checked) {$ (' #select ') [0].checked = false;} else if ($ (this) [0].checked) {if ($ (' input[name=sca]:checked '). length = = ckslength) {$ (' #select ') [0].checked = True;}}); * * Anti-select */

<!--page Select all button--><input type= ' checkbox ' id= ' select ' name= "select" onclick= "SelectAll ();" /><input type= "checkbox" Name= "ITo" onclick= ' Getrowvalue (this); ' > select 1<input type= "checkbox" Name= "ITo" onclick= ' Getrowvalue (this); ' > select 2<input type= "checkbox" Name= "ITo" onclick= ' Getrowvalue (this); ' > select 3<input type= "checkbox" Name= "ITo" onclick= ' Getrowvalue (this); ' > select 4<input type= "checkbox" Name= "ITo" onclick= ' Getrowvalue (this); ' > Selection 5

When using JS to append a line <input type= ' checkbox ' name= ' ITo '/> Select 6 o'clock.

The Click Function has been unable to listen to the "Select 6". This should be used

Live function

The live () method attaches one or more event handlers to the selected element, and specifies the function to execute when these events occur.



The event handlers attached through the live () method apply to the current and future elements of the matching selector (for example, new elements created by the script).


$ (' Input[name=ito] '). Live ("Click", Function () {       var ckslength = $ (' Input[name=ito] '). Length;if (!$ (this) [0]. Checked) {$ (' #select ') [0].checked = false;} else if ($ (this) [0].checked) {if ($ (' input[name=ito]:checked '). length = = ckslength) {$ (' #select ') [0].checked = True;}}    });





JS control checkbox Get Select all Select All not select All selected is not selected All selection is selected

Related Article

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.