zoukankan      html  css  js  c++  java
  • jquery中实现全选按钮

    <html>
      <head>
      <script type='text/javascript' src='js/jquery-1.5.1.js'></script>
      <script type='text/javascript'>
        $(document).ready(function(){
       $('#handle').click(function(){
         if($(this).attr('checked')==true){
       $('.toggle').attr('checked','true');
       }
      else{
       $('.toggle').removeAttr('checked');
       }
       });
       $('.toggle').click(function(){
         if($('.toggle:checked').length==$('.toggle').length){
         $('#handle').attr('checked','true');
         }
      else{
        $('#handle').removeAttr('checked');
        }
      });
     });
      </script> 
      <style type='text/css'>
      ul{
         background-color:#ccc;
      list-style:none;
      margin 20px auto;
      }
      li{
        padding:10px;
     }
      </style>
      </head>
      <body>
        <ul>
       <li>
        <input type='checkbox' id='handle'>
           <label for='handle'>
          <strong> Toggle ALL</strong></label>
      </li>
       <li>
         <input type='checkbox' class='toggle'>
         <label> aaaaaaa</label>
         </li>
       <li>
         <input type='checkbox' class='toggle'>
         <label> bbbbbbb</label>
         </li>
       <li>
         <input type='checkbox' class='toggle'>
         <label> cccccccc</label>
         </li>
       <li>
         <input type='checkbox' class='toggle'>
         <label> ddddddd</label>
         </li>
     </ul>
      </body>
     </html>

  • 相关阅读:
    Windows Server 2012 R2 或 2016 无法安装 .Net 3.5.1
    织梦DeDeCms会员登录或退出跳转到首页的修改方法
    use ngCordova in ionic
    Angular2 Todo App
    use traceur in ES6
    Angular2 Use styles in Component
    Angular2 use ng-xx (ng-if)
    Angular2 Router
    Angular2 Http
    1 TypeScript SetUp for Webstorm
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/3150351.html
Copyright © 2011-2022 走看看