title: how to check and uncheck all checkboxes in an html table with checking/unchecking one check box?
body: <p>I have a table, with rows, every row has a check box, and there is a main check box at the <code>thead</code>. My code:</p>
  
  <pre><code>&lt;table border="1"&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;&lt;input type="checkbox" id="allcb" name="allcb"/&gt;&lt;/th&gt;
              &lt;th&gt;values&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="checkbox" id="cb1" name="cb1"/&gt;&lt;/td&gt;
              &lt;td&gt;value1&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="checkbox" id="cb2" name="cb2"/&gt;&lt;/td&gt;
              &lt;td&gt;value2&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="checkbox" id="cb3" name="cb3"/&gt;&lt;/td&gt;
              &lt;td&gt;value3&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>(also try it <a href="http://jsfiddle.net/xYAfj/" rel="noreferrer">here</a>)</p>
  
  <p>Could anyone help me, how to do that if I check the main check box at the top, all check boxes will be checked, if I uncheck the main, all checkboxes will be unchecked.
  Thank you if you help me!</p>