zoukankan      html  css  js  c++  java
  • jquery版的全选,全不选和反选

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
    <title></title>
    </head>
    <body>
    <div id="content">
    <p>
    <input type="checkbox" name="" id="" value="" />打篮球
    </p>
    <p>
    <input type="checkbox" name="" id="" value="" />打篮球
    </p>
    <p>
    <input type="checkbox" name="" id="" value="" />打篮球
    </p>
    <p>
    <input type="checkbox" name="" id="" value="" />打篮球
    </p>
    <p>
    <input type="checkbox" name="" id="" value="" />打篮球
    </p>
    </div>
    <input type="button" name="" id="quanxuan" value="全选" />
    <input type="button" name="" id="buxuan" value="全不选" />
    <input type="button" name="" id="fanxuan" value="反选" />
    </body>
    <script type="text/javascript">
    $(function(){
    $("#quanxuan").click(function(){
    $(":checkbox").attr({"checked":true});//此方法不能使用太高jq版本
    });
    $("#buxuan").click(function(){
    $(":checkbox").attr({"checked":false});
    });
    $("#fanxuan").click(function(){
    $(":checkbox").each(function(){
    //this.checked=!this.checked;
    $(this).attr('checked',!$(this).attr('checked'));
    })
    });
    })
    </script>
    </html>

  • 相关阅读:
    Java
    HashMap数据结构与实现原理解析(干货)
    Java
    Java
    Java
    面向对象基础
    Java
    Java
    Java
    shell脚本
  • 原文地址:https://www.cnblogs.com/luoguixin/p/6225299.html
Copyright © 2011-2022 走看看