Dom 学习总结以及实例的使用介绍(9)


复选框选择
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
     <title>欢迎来到daomul的博客,欢迎再来,谢谢(歌曲选择)</title>
     <script type="text/javascript">
         function selAll() {
             var div1 = document.getElementById("playlist");
             var input1 = div1.getElementsByTagName("input");
             for (var i = 0; i < input1.length; i++) {
                 if (input1[i].type == "checkbox") {
                     input1[i].checked = "checked";
                 }
             }
         }
         function deSelAll() {
             var div1 = document.getElementById("playlist");
             var input1 = div1.getElementsByTagName("input");
             for (var i = 0; i < input1.length; i++) {
                 if (input1[i].type == "checkbox") {
                     input1[i].checked = "";
                 }
             }
         }
         function reverseSel() {
             var div1 = document.getElementById("playlist");
             var input1 = div1.getElementsByTagName("input");
             for (var i = 0; i < input1.length; i++) {
                 if (input1[i].type == "checkbox") {
                     if (input1[i].checked == true) {
                         input1[i].checked = false;
                     }
                     else{
                         input1[i].checked = true;
                     }
                 }
             }
         }
     </script>
 </head>
 <body>
     <div>
         <input type="checkbox" /><label for="p1">leaving into the dog</label><br />
         <input type="checkbox" /><label for="p1">take a shower</label><br />
         <input type="checkbox" /><label for="p1">fire heart</label><br />
         <input type="checkbox" /><label for="p1">china</label><br />
         <p>
             <input type="button" value="全选" />
             <input type="button" value="全不选" />
             <input type="button" value="反选" />
         </p>
     </div>
 </body>
 </html>


案例4:权限选择

复制代码 代码如下:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wdgfxj.html