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


  • 相关阅读:
    CS231n笔记 Lecture 4 Introduction to Neural Networks
    CS231n笔记 Lecture 3 Loss Functions and Optimization
    CS231n笔记 Lecture 1 Introduction
    LeetCode
    Python备忘录
    Celery简介
    SaltStack error: No module named 'salt'
    IO模型
    TCP协议的三次握手和四次分手
    第一章:正则表达式
  • 原文地址:https://www.cnblogs.com/baobeiqi-e/p/9884832.html
Copyright © 2011-2022 走看看