title: Select all checkboxes in generated table
body: <p>I need to select all checkboxes in generated table. I've used this jquery code but it seems it's not working. Checkbox is shown. Sorry for this messy code, but I was unsure what is important and whats not.
  Thank you for any help guys</p>
  
  <pre><code>&lt;input type="checkbox" id="selectAll" /&gt;
      &lt;table&gt;
          &lt;tbody&gt;
              &lt;tr class='edit_row'&gt;
                  &lt;input type='hidden' name='fields[]' value='&lt;?php echo $field_id; ?&gt;' /&gt;
                  &lt;td&gt;&lt;label class='edit_label' for='&lt;?php echo $name; ?&gt;'&gt;&lt;?php echo $label; ?&gt;&lt;/label&gt;&lt;/td&gt;
                  &lt;td&gt;
  &lt;?php if ($type == 'checkbox') {  ?&gt;
  &lt;?php   $checked = ($value == 'checked') ? " checked='checked'" : ''; ?&gt;
                      &lt;label&gt;
                          &lt;input id='&lt;?php echo $name; ?&gt;' class='edit_checkbox' type='checkbox' name='&lt;?php echo $name; ?&gt;' value='checked'&lt;?php echo $checked; ?&gt; /&gt;
                      &lt;/label&gt;
  &lt;?php } elseif ($type == 'date') { ?&gt;   
                      &lt;input id='&lt;?php echo $name; ?&gt;'&lt;?php echo $class; ?&gt; type='text' name='&lt;?php echo $name; ?&gt;' value='&lt;?php echo $value; ?&gt;' /&gt;
  &lt;?php } elseif ($type == 'radio') { ?&gt;                      
                      &lt;?php $this-&gt;radio_buttons($field_id, $name, $value, $required); ?&gt;                 
  &lt;?php } elseif ($type == 'select') { ?&gt;     
                      &lt;select id='&lt;?php echo $name; ?&gt;'&lt;?php echo $class; ?&gt; name='&lt;?php echo $name; ?&gt;'&gt;
                          &lt;?php $this-&gt;select_options($field_id, $value); ?&gt;
                      &lt;/select&gt;
  &lt;?php } elseif ($type == 'text') { ?&gt;
                      &lt;input id='&lt;?php echo $name; ?&gt;'&lt;?php echo $class; ?&gt; type='text' name='&lt;?php echo $name; ?&gt;' value='&lt;?php echo $value; ?&gt;' /&gt;
  &lt;?php } elseif ($type == 'textarea') {  ?&gt;
                      &lt;textarea id='&lt;?php echo $name; ?&gt;'&lt;?php echo $class; ?&gt; name='&lt;?php echo $name; ?&gt;'&gt;&lt;?php echo $value; ?&gt;&lt;/textarea&gt;                           
  &lt;?php } ?&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
  &lt;?php if ($required) { ?&gt;
                      &lt;span class='required_input'&gt;&lt;?php _e('Required', CA_PLUGIN_NAME); ?&gt;&lt;/span&gt;
  &lt;?php } ?&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
  &lt;?php } ?&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
  &lt;script&gt;
  
      $( document ).ready(function() {
          $('#selectAll').click(function(e){
              var table= $(e.target).closest('table');
              $('td input:checkbox',table).prop('checked',this.checked);
          });
      console.log( "I'm alive!" );
  });
  
  &lt;/script&gt;
  &lt;?php //END
  </code></pre>
  
  <p><strong>Update</strong></p>
  
  <p>This is the code I'm using now. Sadly, it still not working</p>
  
  <pre><code>&lt;input type="checkbox" id="selectAll" /&gt;
      &lt;table&gt;
          &lt;tbody&gt;
  &lt;?php
              &lt;tr class='edit_row'&gt;
                  &lt;input type='hidden' name='fields[]' value='&lt;?php echo         $field_id; ?&gt;' /&gt;
                  &lt;td&gt;&lt;label class='edit_label' for='&lt;?php echo $name; ?&gt;'&gt;&lt;?    php echo $label; ?&gt;&lt;/label&gt;&lt;/td&gt;
                  &lt;td&gt;
  &lt;?php if ($type == 'checkbox') {  ?&gt;
  &lt;?php   $checked = ($value == 'checked') ? " checked='checked'" : ''; ?&gt;
                      &lt;label&gt;
                          &lt;input id='&lt;?php echo $name; ?&gt;'     class='edit_checkbox checkBoxClass' type='checkbox' name='&lt;?php echo $name; ?&gt;'     value='checked'&lt;?php echo $checked; ?&gt; /&gt;
                      &lt;/label&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
  &lt;?php } ?&gt;
          &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;script&gt;
  
      $( document ).ready(function() {
          $("#selectAll").click(function () {
              $(".checkBoxClass").prop('checked', $(this).prop('checked'));
          });
  
      console.log( "ready!" );
  });
  
  &lt;/script&gt;
  </code></pre>