Select All Checkboxes using jQuery – Demo and Example Script.

Today we are going to see how to make all the checkboxes checked when the user clicks the top checkbox ie., (Select All checkbox) . This script is really easy and is often needed in many situation.

Here is the Select All Function,  this script has only two lines 🙂

#selectall is the top checkbox (selectAll) when the user click the element it will see the other checkboxes are selected or not.
if no then it will select all, if yes, then it will deselect all.

.mycheckbox is the class used in all the other checkboxes.

Moreover, If the user manually select all the other checkboxes then we need to select the top check box right?. Here is the script for that.

Here is the Usage example code (just double click and copy the entire script in notepad, save it as html and test yourself):

Here is the demo for you:

demo_btn

One Comment

Add a Comment

Your email address will not be published. Required fields are marked *