zoukankan      html  css  js  c++  java
  • jq 全选和反选以及判断那条被选中

    <body>
    <div><input type="checkbox" id="a" />全选</div>
    <div><input type="checkbox" class="b" value="aa" />aa</div>
    <div><input type="checkbox" class="b" value="bb"  />bb</div>
    <div><input type="checkbox" class="b" value="cc"  />cc</div>
    <div><input type="button" id="d" value="获取" /></div>
    </body>
    <script type="text/javascript">
    $(document).ready(function(e) {
        $("#a").click(function(){
            
            var xz = $(this).prop("checked");  //判断a是否被选中
            
            $(".b").prop("checked",xz);  //让b的属性与a一样
            
        })
        $("#d").click(function(){
            var attr=new Array();  //建立一个数组
            $(".b").each(function(){  //each循环遍历b
                if($(this).prop("checked"))  //判断被循环的这一条是否被选中
                {
                       attr.push($(this).val());  //把被选中的数据添加到数组
                }
            });
            alert(attr);
            
        })
    });
    </script>
    </html>

  • 相关阅读:
    批量管理 页面空间
    WinForm 程序Post GEt web程序方法
    ASP.NETSession详解
    ASP.NET 中实现会话状态的基础
    ASP.NET验证控件详解
    StringHelper类
    PowerDesigne 笔记
    asp.ent 会话标识ID
    常用正则表达式
    HashMap中的keySet
  • 原文地址:https://www.cnblogs.com/bilibiliganbei/p/6019192.html
Copyright © 2011-2022 走看看