title: Count selected checkboxes using jquery.
body: <p>I'm trying to count the number of checkboxes that have been checked. But, the count remains 0 even though I click. Here is my code.</p>
  
  <pre><code>&lt;div&gt;
  &lt;input type="checkbox" class="category1"&gt;&lt;/input&gt;
  &lt;input type="checkbox" class="category1"&gt;&lt;/input&gt;
  &lt;input type="checkbox" class="category1"&gt;&lt;/input&gt;
  &lt;input type="checkbox" class="category1"&gt;&lt;/input&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>and my JS code is..</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
          $(document).ready(function(){
  
              $(".category1").click(function(){
  
                  var category1Count = $('.category1 :checked').size();
                  console.log(category1Count);
              });
  
  
          });
      &lt;/script&gt;
  </code></pre>
  
  <p>There must be a simple mistake. Not able to find out. Where am I going wrong? Thanks in advance</p>