title: Select all checkboxes with a text link
body: <p>I have made a form with a "Select All" checkbox that selects all the other checkboxes within that that form.</p>
  
  <p>I want to modify it so the select all function will work off of a text link, like below:</p>
  
  <p><strong>Link</strong></p>
  
  <pre><code>&lt;a href="#' id="checkall"&gt;Select all checkboxes&lt;/a&gt;
  </code></pre>
  
  <p>Currently it works as below using another checkbox to select all the other checkboxes</p>
  
  <p><strong>Form</strong></p>
  
  <pre><code>&lt;form action="#" method="post" id="myform"&gt;
  
  &lt;fieldset&gt;
  &lt;div class="radio"&gt;&lt;input type="checkbox" name="checkall" id="checkall"&gt; &lt;label for="checkall"&gt;Check all&lt;/label&gt;&lt;/div&gt;
  
  &lt;div class="radio"&gt;&lt;input type="checkbox" name="checkbox1" id="checkbox1"&gt; &lt;label for="checkbox1"&gt;Checkbox&lt;/label&gt;&lt;/div&gt;
  &lt;div class="radio"&gt;&lt;input type="checkbox" name="checkbox2" id="checkbox2"&gt; &lt;label for="checkbox2"&gt;Checkbox&lt;/label&gt;&lt;/div&gt;
  &lt;div class="radio"&gt;&lt;input type="checkbox" name="checkbox3" id="checkbox3"&gt; &lt;label for="checkbox3"&gt;Checkbox&lt;/label&gt;&lt;/div&gt;
  &lt;div class="radio"&gt;&lt;input type="checkbox" name="checkbox4" id="checkbox4"&gt; &lt;label for="checkbox4"&gt;Checkbox&lt;/label&gt;&lt;/div&gt;
  &lt;div class="radio"&gt;&lt;input type="checkbox" name="checkbox5" id="checkbox5"&gt; &lt;label for="checkbox5"&gt;Checkbox&lt;/label&gt;&lt;/div&gt;
  
  &lt;div class="radio"&gt;&lt;input type="checkbox" name="checkbox6" id="checkbox6"&gt; &lt;label for="checkbox6"&gt;Checkbox&lt;/label&gt;&lt;/div&gt;
  &lt;div class="radio"&gt;&lt;input type="checkbox" name="checkbox7" id="checkbox7"&gt; &lt;label for="checkbox7"&gt;Checkbox&lt;/label&gt;&lt;/div&gt;
  &lt;div class="radio"&gt;&lt;input type="checkbox" name="checkbox8" id="checkbox8"&gt; &lt;label for="checkbox8"&gt;Checkbox&lt;/label&gt;&lt;/div&gt;
  &lt;div class="radio"&gt;&lt;input type="checkbox" name="checkbox9" id="checkbox9"&gt; &lt;label for="checkbox9"&gt;Checkbox&lt;/label&gt;&lt;/div&gt;
  &lt;div class="radio"&gt;&lt;input type="checkbox" name="checkbox10" id="checkbox10"&gt; &lt;label for="checkbox10"&gt;Checkbox&lt;/label&gt;&lt;/div&gt;
  
  &lt;/fieldset&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>Script</strong></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(function () {
  $('#checkall').click(function () {
      $('fieldset').find(':checkbox').attr('checked', this.checked);
  });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>I've looked online and can't find a solution for this, any help will be greatly appreciated, thanks</p>