title: How to Make Select All Check Box
body: <p>I want when i click select all then all checkbox will selected and when I click again all checkbox will deselect.</p>
  
  <p>but when I click it nothing happen.</p>
  
  <p>my code</p>
  
  <p><a href="https://jsfiddle.net/qa2fkpyv/2/" rel="nofollow noreferrer">jsfiddle link</a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() {
    $("#check-all").click(function() {
      var check = $(this).attr('checked');
      if (check == "checked") {
        $("#deleteid").attr('checked', 'checked');
      } else
        $("#deleteid").removeAttr('checked');
    });
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;form id="sort_select_delete_form" method="get"&gt;
  
    &lt;div class="btn-group"&gt;
      &lt;a href="#check-all" class="btn btn-primary" id="check-all"&gt;Select All&lt;/a&gt;
      &lt;input type="submit" class="btn btn-danger" value="Delete Selected"&gt;
    &lt;/div&gt;
  
    &lt;input class="form-check-input" type="checkbox" value="1000000001" id="deleteid[]" name="deleteid[]"&gt;select1
    &lt;input class="form-check-input" type="checkbox" value="1000000002" id="deleteid[]" name="deleteid[]"&gt;select2
    &lt;input class="form-check-input" type="checkbox" value="1000000003" id="deleteid[]" name="deleteid[]"&gt;select3
    &lt;input class="form-check-input" type="checkbox" value="1000000004" id="deleteid[]" name="deleteid[]"&gt;select4
    &lt;input class="form-check-input" type="checkbox" value="1000000005" id="deleteid[]" name="deleteid[]"&gt;select5
  
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>