title: How do I count how many checkboxes are selected on a page with jQuery
body: <p>I want to count how many checkboxes on my page are selected using jQuery.  I've written the following code:</p>
  
  <pre><code>      var numberOfCheckboxesSelected = 0;
        $(':checkbox').each(function(checkbox) {
            if (checkbox.attr('checked'))
                numberOfCheckboxesSelected++;
        });
  </code></pre>
  
  <p>However, my code errors out with the message "Object doesn't support this property or method" on the third line.</p>
  
  <p>How do I count how many checkboxes are selected on my page?</p>