Idea: 1, get the element. 2, with a For loop calendar array, the checkbox checked set to True to achieve the full selection, the checkbox checked set to False is not selected. 3, through if judgment, 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 selected state.
JS Code:
1 <script> 2 window.onload=function () {3 var Checkall=document.getelementbyid (' All '); 4 var uncheck=documen T.getelementbyid (' uncheck '); 5 var Othercheck=document.getelementbyid (' Othercheck '); 6 var Div=document.getelementbyid (' div '); 7 var checkbox=div.getelementsbytagname (' input '); 8 Checkall.onclick=function () {9 for (i=0;i<checkbox.length;i++) {CHECKBOX[I].CHEC Ked=true;11};12};13 uncheck.onclick=function () {+ for (i=0;i<checkbox.length;i + +) {checkbox[i].checked=false;16};17};18 othercheck.onclick=function ( {i=0;i<checkbox.length;i++) {$ if (checkbox[i].checked==true) {21 Checkbox[i].checked=false;22}23 else{24 Checkbox[i].checked=true25}26 27};28};29};30 </script>
HTML code:
1 Select all: <input type= "button" id= "All" value= "Select All"/><br/> 2 uncheck <input type= "button" id= "uncheck" value= "not selected"/& Gt;<br/> 3 Reverse selection <input type= "button" id= "Othercheck" value= "Reverse Selection"/><br/> 4 <div id= "div" > 5 < Input type= "checkbox"/><br/> 6 <input type= "checkbox"/><br/> 7 <input type= "checkbox" /><br/> 8 <input type= "checkbox"/><br/> 9 <input type= "checkbox"/><br/>10 <input type= "checkbox"/><br/>11 <input type= "checkbox"/><br/>12 <input type= "Chec Kbox "/><br/>13 <input type=" checkbox "/><br/>14 <input type=" checkbox "/><br/> ; <input type= "checkbox"/><br/>16 <input type= "checkbox"/><br/>17 <input type = "checkbox"/><br/>18 <input type= "checkbox"/><br/>19 <input type= "checkbox"/><b R/>20 <inputtype= "checkbox"/><br/>21 <input type= "checkbox"/><br/>22 <input type= "checkbox"/>& LT;BR/>23 <input type= "checkbox"/><br/>24 <input type= "checkbox"/><br/>25 </div >
JS implementation of the full selection, not select, reverse selection