title: check uncheck All checkboxes with another single checkbox use jquery
body: <p>I use jquery-1.9.1.js
  In my html page, it works well for the first time.</p>
  
  <p>just like        <a href="http://jsfiddle.net/pzCcE/1/">http://jsfiddle.net/pzCcE/1/</a></p>
  
  <p>Can somebody help me to improve it?</p>
  
  <pre><code>&lt;table id="tab1"&gt;
      &lt;input type="checkbox" name="checkAll" id="checkAll"&gt;全選
      &lt;input type="checkbox" name="book" id="book" value="book1"&gt;book1
      &lt;input type="checkbox" name="book" id="book" value="book2"&gt;book2
      &lt;input type="checkbox" name="book" id="book" value="book3"&gt;book3
      &lt;input type="checkbox" name="book" id="book" value="book4"&gt;book4
      &lt;input type="checkbox" name="book" id="book" value="book5"&gt;book5&lt;/table&gt;
  
  $(function () {
      $("#tab1 #checkAll").click(function () {
          if ($("#tab1 #checkAll").is(':checked')) {
              $("#tab1 input[type=checkbox]").each(function () {
                  $(this).attr("checked", true);
              });
  
          } else {
              $("#tab1 input[type=checkbox]").each(function () {
                  $(this).attr("checked", false);
              });
          }
      });
  });
  </code></pre>