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