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');
                }
            });
        });
    });

  • 相关阅读:
    Qt 交换Layout中的QWidget控件位置
    霍夫变换(Hough)
    图像傅里叶变换
    通俗讲解:图像傅里叶变换
    傅里叶分析之掐死教程(完整版)
    一幅图弄清DFT与DTFT,DFS的关系
    Qt 实现简单的TCP通信
    Qt 基于TCP的Socket编程
    Socket原理讲解
    科研相机选择:sCMOS还是CCD?
  • 原文地址:https://www.cnblogs.com/baobeiqi-e/p/9884833.html
Copyright © 2011-2022 走看看