title: How to select all checkbox by button
body: <p>I'd like to select all input checkbox field on jquery event button click but when I click the button nothing happens</p>
  
  <p>JQUERY</p>
  
  <pre><code>$('#selAll').on('click', function() {
     $(".cb").attr('checked', $(this).is(":checked"));
  });
  </code></pre>
  
  <p>HTML</p>
  
  <pre><code>    &lt;input type="button" value="Select All" class="btn" id="selAll" /&gt;
      &lt;input type="checkbox" name="a" value="1" class="cb"&gt;
      &lt;input type="checkbox" name="b" value="1" class="cb"&gt;
  </code></pre>
  
  <p>which is the best/right solution to do this? thanks
  <a href="http://jsfiddle.net/zUGw6/2/" rel="nofollow">JsFiddle example</a></p>