实现全选按钮的js代码

 

            //全选,取消全选
            $(document).on("click","#selection",function(){
                if($(this).hasClass("selected")==false){
                    $(this).closest(".tablesWrap").find("input[type=checkbox]").prop("checked",true);
                    $(this).addClass("selected");
                }else{
                    $(this).closest(".tablesWrap").find("input[type=checkbox]").prop("checked",false);
                    $(this).removeClass("selected");
                }
            });
 
 
.tablesWrap便是包含所有复选框的类名。
posted @ 2016-08-25 23:51  有一个小白  阅读(2929)  评论(0)    收藏  举报