zoukankan      html  css  js  c++  java
  • 案例5:全选和反选

    <script>
      $(function(){
        //  方式一:
        $("#allCheck").change(function(){
        if($(this).prop("checked")==true){
          $(".check").each(function(){
            $(this).prop("checked",true);
          })
        }else{
          $(".check").each(function(){
            $(this).prop("checked",false);
          })
        }
     
        //   方式二:   
        $(".check").prop("checked",$(this).prop("checked"));  //   把子元素的所有选框设置为和全选框一样的值
      })
    })
    </script>
    </head>
    <body>
    <div>
      <input type="checkbox" id="allCheck" value="全选">全选
    </div>
    <ul>
      <li><input type="checkbox" class="check" id="">例1</li>
      <li><input type="checkbox" class="check" id="">例2</li>
      <li><input type="checkbox" class="check" id="">例3</li>
      <li><input type="checkbox" class="check" id="">例4</li>
    </ul>
    </body>
  • 相关阅读:
    linux批量远程多服务器FTP并下载文件的脚本
    NPM更换国内源
    Win10禁用无用的服务
    JS测试
    FastAdmin导出
    VScode全局设置
    Vue路由history模式
    kill_devtmpfsi
    获取域名URL
    Axios去除Respones中的config、headers、request
  • 原文地址:https://www.cnblogs.com/qtbb/p/11336741.html
Copyright © 2011-2022 走看看