zoukankan      html  css  js  c++  java
  • 简单的全选和下拉菜单

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <style>
      ul{
        list-style: none;
      }
      .menu{
        display: none;
      }
    </style>
      <meta charset="UTF-8">
      <title></title>
    </head>
    <body>
      <div class="container">
       <ul>
            <li>
              <input type="checkbox" name="checkbox" class="allchose" /><span>车队1</span><span class="btn"> +</span>
              <ul class="menu">
                <li>
                  <input type="checkbox" name="checkbox1" />1号车
                </li>
                <li>
                  <input type="checkbox" name="checkbox2" />2号车
                </li>
                <li>
                  <input type="checkbox" name="checkbox3" />3号车
                </li>
                <li>
                  <input type="checkbox" name="checkbox4" id="checkbox4" />4号车
                </li>
              </ul>
            </li>
            <li>
              <input type="checkbox" name="checkbox" class="allchose" /><span>车队2</span><span class="btn"> +</span>
              <ul class="menu">
                <li>
                  <input type="checkbox" name="checkbox1" />1号车
                </li>
                <li>
                  <input type="checkbox" name="checkbox2" />2号车
                </li>
                <li>
                  <input type="checkbox" name="checkbox3" />3号车
                </li>
                <li>
                  <input type="checkbox" name="checkbox4" id="checkbox4" />4号车
                </li>
              </ul>
            </li>
          </ul>
      </div>
    </body>
    <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
    <script>
      $(function(){
        $('.btn').click(function(){
          var $menu = $(this).siblings('.menu');
          var flag = $menu.is(':hidden');
          if(flag){
            $menu.slideDown(200);
          }else{
            $menu.slideUp(200);
          };
        });
        
        $('.allchose').click(function(){
           var t = $(this).siblings('.menu').find("input[type='checkbox']");
          if($(this).is(":checked")){
            t.prop("checked",true);
            console.log('我已经被旋转');
          }else{
            t.prop("checked",false);
          }
        })
      })
    </script>
    <script>
    
    </script>
    </html>

  • 相关阅读:
    Android入门:Button
    Android入门:部署时的常见错误
    to be
    Android入门:单元测试
    忘记 MySQL 的 root 帐号密码该怎么办
    Eclipse开发build path中jar包部署到应用中
    报告两个bug
    本站导引
    一个用Word做报表设计的报表系统windwardreports
    智能互联网
  • 原文地址:https://www.cnblogs.com/TTTK/p/6307541.html
Copyright © 2011-2022 走看看