Jquery “select all” checkbox

后端 未结 11 654
执念已碎
执念已碎 2020-12-06 05:45

I am trying to select all checkboxes on a page once the \'select all\' checkbox is clicked and i am using jquery for this as you can see at the below link:

http://js

11条回答
  •  佛祖请我去吃肉
    2020-12-06 06:25

    $(function(){

    // add multiple select / deselect functionality
    $("#selectall").click(function () {
          $('.case').attr('checked', this.checked);
    });
    
    // if all checkbox are selected, check the selectall checkbox
    // and viceversa
    $(".case").click(function(){
    
        if($(".case").length == $(".case:checked").length) {
            $("#selectall").attr("checked", "checked");
        } else {
            $("#selectall").removeAttr("checked");
        }
    
    });
    

    });

提交回复
热议问题