title: Checkbox checkall/uncheckall (Quick help)
body: <p>I wanted a check/uncheck all button using jquery or javascript.
  I have tried using examples available in net, but nothing worked for me.</p>
  
  <pre><code>&lt;li&gt;
      &lt;span class="checkbox unchecked"&gt;
            &lt;label for="check1"&gt;&lt;/label&gt;
            &lt;input type="checkbox" id="select" name="select"&gt;
      &lt;/span&gt;
  &lt;/li&gt;
  </code></pre>
  
  <p>This is how I have place all my checkboxes in loop containing some information.
  I have called this from another jsp page and place it in a form in another.
  I tried possible examples but could not get working these code.</p>
  
  <p>Please help.</p>
  
  <p>I have tried this jQuery:</p>
  
  <pre><code>&lt;script language="javascript"&gt;
  $(function(){
      $("#select").click(function () {
          $('#check1').attr('checked', this.checked);
      });
      // if all checkbox are selected, check the select checkbox
      // and viceversa
      $("#check1").click(function(){
          if($("#check1").length == $("#check1:checked").length) {
              $("#select").attr("checked", "checked");
          } else {
              $("#select").removeAttr("checked");
          }
  
      });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>I am not allowed to change the design and css of this checkbox.</p>