mercredi 9 août 2017

How to get the total count of checkboxes of based on particular class

Hi everyone, I have get stuck in getting the total number of checkboxes of checked checkboxes when I click select all as code shown below

$("#SelctCheckAll").click(function () {
        $('input:checkbox').not(this).prop('checked', this.checked);
        var numberOfChecked = $('input:checkbox:checked').length;
        var totalCheckboxes = $('input:checkbox').length;
    });

so its working fine. But my doubt is when i add two classes such as class="checkbox1" and class="checkbox2" both having type=checkbox. for example- class=checkbox1 contains 6 checkboxes and class=checkbox2 contains 10 checkboxes. So how to get total number of checkboxes of class=checkbox1 and viceversa. sample below

<input type="checkbox" id="SelctCheckAll" name="SelctCheckAll">
<input type="checkbox" class="checkbox1">
<input type="checkbox" class="checkbox2">




Aucun commentaire:

Enregistrer un commentaire