zoukankan      html  css  js  c++  java
  • jQuery使用prop设置checkbox全选、反选

    $(function(){
        var checkbox = $("input[type='checkbox']");
        //全选
        $('#select-all').click(function(){
            checkbox.prop("checked", true);
        });
        //反选
        $('#select-reverse').click(function(){
            checkbox.prop("checked", function(index, attr){
                return !attr;
            });
        });

    });





        $(document).ready(function(){
                $("#allsel").click(function(){
            
                //prop全选
                var is =$(this).prop("checked");
                $("table :checkbox").prop("checked",is);
                
                });
                
                $("table :checkbox").click(function(){
                    $("#allsel").prop("checked",true);
                    $("table :checkbox").each(function(){
                        var is = $(this).prop("checked");
                        if(is==false){
                        $("#allsel").prop("checked",false);
                        }
                    });
                });
                
                //prop反选
                $("#notsel").click(function(){
                    $("table :checkbox").prop("checked",function(i,val){
                        return !val;
                    
                    });
                
                });
            });
       


  • 相关阅读:
    ssh环境的搭建,基于注解和配置文件使用
    myeclipse db browser 新建数据源
    区别jquery对象和dom对象及转换方法
    C++中map容器的说明和使用技巧
    csh shell 语法 例子
    如何选择显示器
    Vim简明教程【CoolShell】
    perl
    perlretut
    ssh 配置详解
  • 原文地址:https://www.cnblogs.com/baobeiqi-e/p/9884832.html
Copyright © 2011-2022 走看看