zoukankan      html  css  js  c++  java
  • 复选框的全选效果

    <!DOCTYPE html>
    <html>
    <head>
      <title>test page</title>
      <meta http-equiv="content-type" content="text/html;charset=utf-8">
    </head>
    <body>
    <input type="checkbox" name="sports[]" value="0">足球
    <input type="checkbox" name="sports[]" value="10">篮球
    <input type="checkbox" name="sports[]" value="20">排球
    <input type="checkbox" name="sports[]" value="30">乒乓球
    <input type="checkbox" name="sports[]" value="40">羽毛球
    <input type="checkbox" name="sports[]" value="50">橄榄球
    <input type="checkbox" name="sports[]" value="60">冰球
    <input type="checkbox" name="sports[]" value="70">曲棍球
    <input type="checkbox" name="sports[]" value="80">同求
    <input type="checkbox" id="chkAll" onclick="chkAll(this)">全选
    <script type="text/javascript">
      var objs = document.getElementsByName('sports[]');
      function chkAll(obj){
        for (var i = objs.length - 1; i >= 0; i--) {
          objs[i].checked = obj.checked;
        };
      }
    </script>
    </body>
    </html>
    
  • 相关阅读:
    集体编程智慧(发现的一些代码问题)
    jQuery实现图片伦播效果(淡入淡出+左右切换)
    require
    小技巧
    JavaScript--面向对象--猜拳游戏
    简单封装cookie操作
    less
    进程相关

    线程和进程相关
  • 原文地址:https://www.cnblogs.com/anxiaoyu/p/6937401.html
Copyright © 2011-2022 走看看