In order to select all the checkboxes of a page, we need to create a selectAll () function through which we can select all the checkboxes together. In this section, not only we will learn to select all checkboxes, but we will also create another function that will deselect all the checked checkboxes.
We will implement and understand an example where we will create two buttons one for selecting all checkboxes and the other one for deselecting all the selected checkoxes. The example code is given below:
When we click on the 'Select All' button, we get:
When we deselect all checkboxes, we get:
The user can create many such examples of using checkboxes and try out such function.
So, in this way the user can select all or deselect all checkboxes.