How to select all checkboxes with jQuery? How to select all checkboxes with jQuery? javascript javascript

How to select all checkboxes with jQuery?


A more complete example that should work in your case:

$('#select_all').change(function() {  var checkboxes = $(this).closest('form').find(':checkbox');  checkboxes.prop('checked', $(this).is(':checked'));});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><form>  <table>    <tr>      <td><input type="checkbox" id="select_all" /></td>    </tr>    <tr>      <td><input type="checkbox" name="select[]" /></td>    </tr>    <tr>      <td><input type="checkbox" name="select[]" /></td>    </tr>    <tr>      <td><input type="checkbox" name="select[]" /></td>    </tr>  </table></form>