Select All checkboxes using jQuery

前端 未结 15 1583
渐次进展
渐次进展 2020-12-05 06:26

I have the following html code:

    
    

15条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-05 06:47

     jQuery( function($){
        // add multiple select / deselect functionality
        $("#contact_select_all").click(function () {
    
            if($("#contact_select_all").is(":checked")){
                $('.noborder').prop('checked',true);
            }else
                $('.noborder').prop('checked',false);
        });
    
        // if all checkbox are selected, check the selectall checkbox
        $(".noborder").click(function(){
    
        if($(".noborder").length == $(".noborder:checked").length) {
            $("#contact_select_all").attr("checked", "checked");
        } else {
            $("#contact_select_all").removeAttr("checked");
        }
    
        });
    
    });
    

提交回复
热议问题