Home >Web Front-end >CSS Tutorial >How to Select All Checkboxes Except `#select_all` with jQuery?

How to Select All Checkboxes Except `#select_all` with jQuery?

DDD
DDDOriginal
2024-11-10 19:47:03506browse

How to Select All Checkboxes Except `#select_all` with jQuery?

Select All Checkboxes Except #select_all with jQuery

In order to manipulate checkboxes using jQuery selectors, you can utilize the following markup:

<form>
  <table>
    <tr>
      <td><input type="checkbox">

To select all checkboxes except for the one with the ID select_all, you can use the below jQuery code:

$('#select_all').change(function() {
  var checkboxes = $(this).closest('form').find(':checkbox');
  checkboxes.prop('checked', $(this).is(':checked'));
});

This script will enable you to select all checkboxes within the form when the #select_all checkbox is clicked.

The above is the detailed content of How to Select All Checkboxes Except `#select_all` with jQuery?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn