Jquery select all if not disabled

后端 未结 4 677
遥遥无期
遥遥无期 2020-12-18 21:46

I am using the following script to select all checkboxes with a given class.

$(document).ready(function(){ // 1
    // 2
    $(\':checkbox.selectall\').on(\'         


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-18 22:10

    Here is what I usually do:

    $(function(){
        $(".selectall").live('change', function(){
            if($(this).is(":checked"))
            {
                $("input:checkbox:not(:disabled)." + $(this).data('checkbox-name')).prop("checked", "true");
            }
            else
            {
                $("input:checkbox:not(:disabled)." + $(this).data('checkbox-name')).prop("checked", "false");
            }
        });
    });
    

    I hope it helps :)

提交回复
热议问题