<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <script type="text/javascript"> window.onload=function(){ var CheckAll=document.getElementById('All'); var UnCheck=document.getElementById('uncheck'); var OtherCheck=document.getElementById('othercheck'); var div=document.getElementById('div'); var CheckBox=div.getElementsByTagName('input'); CheckAll.onclick=function(){ for(i=0;i<CheckBox.length;i++){ CheckBox[i].checked=true; } }; UnCheck.onclick=function(){ for(i=0;i<CheckBox.length;i++){ CheckBox[i].checked=false; } } OtherCheck.onclick=function(){ for(i=0;i<CheckBox.length;i++){ if(CheckBox[i].checked==true){ CheckBox[i].checked=false; } else{ CheckBox[i].checked=true } } } } </script> <body> 全选:<input type="button" id="All" value="全选" /><br /> 不选<input type="button" id="uncheck" value="不选" /><br /> 反选<input type="button" id="othercheck" value="反选" /><br /> <div id="div"> <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/> <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/> <input type="checkbox" /><br/> <input type="checkbox" /><br/> <input type="checkbox" /><br/> <input type="checkbox" /><br/> </div> </body> </html>
全选,反选,不选,单选
最新推荐文章于 2022-12-06 15:05:34 发布