title: Jquery button to reset checkboxes
body: <p>I tried using checkbox rather than buttons it works fine but I wanted to try replacing it with a button. I can't make it work, when I click the button it does check the checkbox that I want but when I try to click it again it won't uncheck. I tried making another button it's not working, the purpose of the second button is to reset the checked boxes and check that box that it requires. Can somebody help me? </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>$("#checkAll").on("click", function() {
    if ($(this).prop("click")) {
      $("input:checkbox.empid:not(:checked), input:checkbox.name:not(:checked)").click();
    } else {
      $("input:checkbox.empid:checked, input:checkbox.name:checked").click();
    }
  });
  
  $("#checkAll").on("click", function() {
    if ($(this).prop("click")) {
      $("input:checkbox.name:not(:checked), input:checkbox.age:not(:checked)").click();
    } else {
      $("input:checkbox.name:checked, input:checkbox.age:checked").click();
    }
  });
  
  $("input").change(function() {
    _tot = $("input").length
    _tot_checked = $("input").length;
    if (_tot != _tot_checked) {
      $("#checkAll").prop('checked', false);
      $("#chkjob").prop('checked', false);
    }
  });
  
  $(function() {
  
    var $chk = $("#grpChkBox input:checkbox");
    var $tbl = $("#basic_table");
  
    $chk.prop('checked', false);
  
    $chk.click(function() {
      var colToHide = $tbl.find("." + $(this).prop("name"));
      $(colToHide).toggle();
    });
  });
  
  $("input:checkbox:not(:checked)").each(function() {
    var column = "table ." + $(this).attr("name");
    $(column).hide();
  });</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;input type="button" id="checkAll" value="List by EmployeeID and Name" /&gt;
  &lt;input type="button" id="chkjob" value="List by Name and Age " /&gt;
  
  
  &lt;div id="grpChkBox"&gt;
    &lt;p&gt;&lt;input type="checkbox" name="empid" class="empid" /&gt; Employee ID&lt;/p&gt;
    &lt;p&gt;&lt;input type="checkbox" name="name" class="name" /&gt; Name&lt;/p&gt;
    &lt;p&gt;&lt;input type="checkbox" name="age" class="age" /&gt; Age&lt;/p&gt;
    &lt;p&gt;&lt;input type="checkbox" name="birth" class="birth" /&gt; Birthdate&lt;/p&gt;
    &lt;p&gt;&lt;input type="checkbox" name="los" class="los" /&gt; Length of Service&lt;/p&gt;
    &lt;p&gt;&lt;input type="checkbox" name="jobtitle" class="jobtitle" /&gt; Job Title&lt;/p&gt;
    &lt;p&gt;&lt;input type="checkbox" name="actions" class="actions" /&gt; actions taken&lt;/p&gt;
    &lt;p&gt;&lt;input type="checkbox" name="tab" class="tab" /&gt; Tax and Benefits&lt;/p&gt;
  &lt;/div&gt;
  &lt;table class="table" id="basic_table"&gt;
    &lt;thead&gt;
      &lt;tr&gt;
  
        &lt;th scope="col" class="empid"&gt;id&lt;/th&gt;
        &lt;th scope="col" class="name"&gt;Name&lt;/th&gt;
        &lt;th scope="col" class="age"&gt;Age&lt;/th&gt;
        &lt;th scope="col" class="birth"&gt;Birthdate&lt;/th&gt;
        &lt;th scope="col" class="los"&gt;Length of Service&lt;/th&gt;
        &lt;th scope="col" class="jobtitle"&gt;Job title&lt;/th&gt;
        &lt;th scope="col" class="actions"&gt;actions taken&lt;/th&gt;
        &lt;th scope="col" class="tab"&gt;tax&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
  
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;th class="empid"&gt;{{$report-&gt;id}}&lt;/th&gt;
        &lt;td class="name"&gt;{{$report-&gt;name}}&lt;/td&gt;
        &lt;td class="age"&gt;{{$report-&gt;age}}&lt;/td&gt;
        &lt;td class="birth"&gt;{{$report-&gt;birthdate}}&lt;/td&gt;
        &lt;td class="los"&gt;{{$report-&gt;length_of_service}}&lt;/td&gt;
        &lt;td class="jobtitle"&gt;{{$report-&gt;job_title}}&lt;/td&gt;
        &lt;td class="actions"&gt;{{$report-&gt;actions}}&lt;/td&gt;
        &lt;td class="tab"&gt;{{$report-&gt;tax}}&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;</code></pre>
  </div>
  </div>
  </p>