码迷,mamicode.com
首页 > 其他好文 > 详细

监听复选框

时间:2017-06-21 16:52:55      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:replace   layui   body   code   data   else   .text   function   find   

1.全部选中按钮

    /*全部选中*/
    $("body").on("click","#all-check",function(){
        var button = $(this);
        var input = $(".layui-table").find("input");
        if(input.is(":checked")){
            input.each(function(){
                this.checked=false;
            }).change()
            button.text("全部选中");    
        }else{
            input.each(function(){
                this.checked=true;
            }).change()
            button.text("全部取消");    
        }
    
    });

2.监听复选框

    $("body").on("change",".layui-table input",function(){
        var id = $(this).parents("tr").attr("data-id");
        if($(this).is(":checked")){
            $("#hidden").append(id+",");
        }else{
            var text = $.trim($("#hidden").text());
            var str =  $.trim(text.replace(id+",",""));
            $("#hidden").html(str);        
        }
    });

 

监听复选框

标签:replace   layui   body   code   data   else   .text   function   find   

原文地址:http://www.cnblogs.com/linsx/p/7060138.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!