監聽復選框


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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM