title: Jquery code doesn't work without alert
body: <pre><code>var countChecked = function () {
    var n = $("input:checked").length;
    $("#count").text(n + (n === 1 ? " is" : " are") + " checked!");
  };
  
  countChecked();
  alert();        // this alert
  
  $("input[type=checkbox]").on("click", countChecked);
  </code></pre>
  
  <p>I use this code to count the number of checkbox inputs that are checked.</p>
  
  <p>With <code>alert()</code> this works well. But without the alert this is not working. How can i fix it?</p>