title: how to prevent checking a checkbox using query
body: <p>I've a group of check boxes in my page and I want to prevent checking a check box from user if he already checked two boxes. Somehow I solved my problem but I'm not satisfied with my current solution because I don't think its the proper way to do the same.  So I'm here for a better option,my current code is given below </p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;input type="checkbox" class="chkTest" /&gt;
  &lt;input type="checkbox" class="chkTest" /&gt;
  &lt;input type="checkbox" class="chkTest" /&gt;
  &lt;input type="checkbox" class="chkTest" /&gt;
  &lt;input type="checkbox" class="chkTest" /&gt;
  &lt;input type="checkbox" class="chkTest" /&gt;
  &lt;input type="checkbox" class="chkTest" /&gt;
  &lt;input type="checkbox" class="chkTest" /&gt;
  &lt;input type="checkbox" class="chkTest" /&gt;
  </code></pre>
  
  <p><strong>Script</strong></p>
  
  <pre><code>    $(function () {
          var count = 0;
          $(".chkTest").change(function () {
  
              if ($(".chkTest").is(":checked")) {
                  count = count + 1;
              }
              if (count &gt; 2) {
                  $(this).attr("checked", false);
                  alert("only two");
              }
  
          });
      });
  </code></pre>
  
  <p>Any thoughts???</p>