Current location - Recipe Complete Network - Food recipes - Jquery realizes check box selection and check box selection.
Jquery realizes check box selection and check box selection.

1. First of all, the structure of the web project is as shown in the figure. If you are familiar with this structure, you can adjust it yourself.

2. Then, set some simple option boxes. Here, just use abcd to replace the option boxes.

3. This is jq to realize all selections, so introduce jQuery and bind a click event of type jQuery to the button.

4. Then set the property of input through prop, which is a method of jq.

5. Because CheckBox can set the checked attribute, we can just set it to true.

6. In the final preview, you can see that the CheckBox have all been checked, thus achieving the selection of all.