How do I count how many checkboxes are selected on a page with jQuery

前端 未结 4 1655
感动是毒
感动是毒 2021-01-01 18:28

I want to count how many checkboxes on my page are selected using jQuery. I\'ve written the following code:

      var numberOfCheckboxesSelected = 0;
               


        
4条回答
  •  甜味超标
    2021-01-01 18:46

    Try this(to avoid counting any selected radio buttons):

    var numberOfCheckboxesSelected = $('input[type=checkbox]:checked').length; 
    

提交回复
热议问题