全选,反选,不选,单选

来源:互联网 发布:专业的数控编程软件 编辑:程序博客网 时间:2024/05/17 04:45
<!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>
0 0
原创粉丝点击