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

    $(document).ready(function(){
                $("#allsel").click(function(){
                /*
                    var is = $(this).attr("checked");
                    if(is=="checked"){
                    $("table :checkedbox").attr("checked",true);
                    }
                */
                //prop
                var is =$(this).prop("checked");
                $("table :checkbox").prop("checked",is);
                
                });
                
                
                $("#notsel").click(function(){
                    $("table :checkbox").prop("checked",function(index,attr){
                        return !attr;
                    
                    });
                
                }
                
                );

            });




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

        //反选
        $('#select-reverse').click(function(){
            checkbox.each(function(i, dom){
                if ( $(dom).attr('checked') ) {
                    $(dom).removeAttr('checked');
                } else {
                    $(dom).attr('checked', 'checked');
                }
            });
        });
    });

  • 相关阅读:
    22 组合电路中的竞争--冒险
    21 典型的组合电路模块(2)
    vhdl和verilog的区别
    17 TTL电路系列(2)
    树莓派Pico
    ESP8266/ESP32自动下载电路原理分析
    CH340芯片
    26. 删除排序数组中的重复项
    25. K 个一组翻转链表
    23. 合并K个排序链表
  • 原文地址:https://www.cnblogs.com/baobeiqi-e/p/9884833.html
Copyright © 2011-2022 走看看