title: JQuery check all checkboxes in column
body: <p>I had this table:
  <img src="https://i.stack.imgur.com/S6FCm.png" alt="my table"></p>
  
  <p>When i click 'Check all' in one column, its supposed that all check boxes in that column with be checked and otherwise. 
  Here is my JQuqey:</p>
  
  <pre><code>$(document).ready(function() {
      $('[id^="check_"]').on('click', function(){
          perm_type=$(this).attr('id');
          type=perm_type.substring(6);
  
          if(!($('#check_'+type).attr('checked'))) {
              $("[id^=client_type_"+type+"]").attr('checked', true);
              $('#check_'+type).attr('checked', true);
              }
          else  {
              $("[id^=client_type_"+type+"]").attr('checked',false);
              $('#check_'+type).attr('checked',false);
              }
  
      });
  });
  </code></pre>
  
  <p>There is my html:</p>
  
  <pre><code>echo '&lt;tr bgcolor="'.($bgcol[$inx % 2]).'"&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;';  
              echo '&lt;tr bgcolor="'.($bgcol[$inx % 2]).'"&gt;';           
              echo '&lt;td valign="top" align="center"&gt;&lt;b&gt;';
              echo $row['title'];
              echo '&lt;/b&gt;&lt;/td&gt;';
              echo '&lt;td valign="top" align="center"&gt;';
              echo '&lt;b&gt;Clients Types&lt;/b&gt;';
              echo '&lt;/td&gt;';       
              echo '&lt;td valign="top" align="center"&gt;';
              echo "&lt;input type='checkbox' id='check_select'&gt;  Check all";
              echo '&lt;/td&gt;';
              echo '&lt;td valign="top" align="center"&gt;';
              echo "&lt;input type='checkbox' id='check_insert'&gt; Check all";
              echo '&lt;/td&gt;';
              echo '&lt;td valign="top" align="center"&gt;';
              echo "&lt;input type='checkbox' id='check_update'&gt; Check all";
              echo '&lt;/td&gt;';
              echo '&lt;td valign="top" align="center"&gt;';
              echo "&lt;input type='checkbox' id='check_delete'&gt; Check all";
              echo '&lt;/td&gt;';                   
              echo "&lt;/tr&gt;";
  
              $nr=0;
              $cli = //my query  here;
                $result=$db-&gt;sql_query($cli);
                while($r=$db-&gt;sql_fetchrow($result)){  
              $s =$db-&gt;sql_fetchrow($db-&gt;sql_query(//my query here"));
  
              echo '&lt;tr bgcolor="'.($bgcol[$inx % 2]).'"&gt;';           
              echo '&lt;td&gt;&lt;/td&gt;&lt;td valign="top" align="center"&gt;';
              echo $r['type'];
              echo "&lt;input type='hidden' id='cli_type_id".$nr."' value='".$r['type_id']."'&gt;";
              echo '&lt;/td&gt;';   
              echo '&lt;td valign="top" align="center"&gt;';
              echo "&lt;input type='checkbox' name='rights[".$r['type_id']."][select]' id='client_type_select".$nr."'  value='true' "; echo $s['sel']?"checked":""; echo "&gt;";
              echo '&lt;/td&gt;';
              echo '&lt;td valign="top" align="center"&gt;';
              echo "&lt;input type='checkbox' name='rights[".$r['type_id']."][insert]' id='client_type_insert".$nr."' value='true' "; echo $s['ins']?"checked":""; echo "&gt;";
              echo '&lt;/td&gt;';
              echo '&lt;td valign="top" align="center"&gt;';
              echo "&lt;input type='checkbox' name='rights[".$r['type_id']."][update]' id='client_type_update".$nr."' value='true' "; echo $s['upd']?"checked":""; echo "&gt;";
              echo '&lt;/td&gt;';
              echo '&lt;td valign="top" align="center"&gt;';
              echo "&lt;input type='checkbox' name='rights[".$r['type_id']."][delete]' id='client_type_delete".$nr."' value='true' "; echo $s['del']?"checked":""; echo "&gt;";
              echo '&lt;/td&gt;';                   
              echo "&lt;/tr&gt;";
                $nr++;  
               }
  </code></pre>
  
  <p>The current result is: When 1 check/uncheck for the first time 'check all', it does function, but if i check again 'check all', is doesn't nothing.
  Please anybody help me! </p>