JS implementation of the full selection of non-select
Ideas:
1, Get Element
2, select the Select option to add click events
3, with a For loop checkbox
4, set the checkbox's checked to true to implement the Select all
5, set the checkbox's checked to false to implement the uncheck
6, if judged, if checked is true to select the state, the checked is set to False, if the checked is false, the checked is set to true check state.
HTML code: <input type= "button" value= "Select All" id= "Sele"/> <input type= "button" value= "not selected" id= "SetInterval"/> & Lt;input type= "button" value= "reverse Select" id= "clear"/> <div id= "Checkboxs" > <input type= "checkbox"/>< br/> <input type= "checkbox"/><br/> <input type= "checkbox"/><br/> <input type= "checkbox"/><br/> <input type= "checkbox"/><br/> <input type= "checkbox"/>< br/> <input type= "checkbox"/><br/> <input type= "checkbox"/><br/> <inpu T type= "checkbox"/><br/> <input type= "checkbox"/><br/> <input type= "checkbox"/>&L t;br/> <input type= "checkbox"/><br/> <input type= "checkbox"/><br/> <INP UT type= "checkbox"/><br/> <input type= "checkbox"/><br/> <input type= "checkbox"/>& LT;BR/></div> JS code: <script>window.onload=function () {var Sele=document.getelementbyid (' Sele ');//Get full Select var unsele=document.g Etelementbyid (' setinterval ');//Get not selected Var Clear=document.getelementbyid (' Clear ');//Get inverse var checkbox= document.getElementById (' Checkboxs ');//Get div var checked=checkbox.getelementsbytagname (' input ');//Get Div under input// Select All Sele.onclick=function () {for (i=0;i<checked.length;i++) {checked[i].checked=true} }//not selected Unsele.onclick=function () {for (i=0;i<checked.length;i++) {Checked[i].check Ed=false}}//Anti-select Clear.onclick=function () {for (i=0;i<checked.length;i++) {if (checked[i].checked==true) {checked[i].checked=false} else{ Checked[i].checked=true}}}}</script>
JS Select All not select the reverse selection