Select All Checkbox in JavaScript - Mostlikers

07 January, 2013

Select All Checkbox in JavaScript

In this post we are going to see how to select all the checkbox with JavaScript and jQuery. Selecting all checkbox is a simple task, as it just takes targeting the required checkbox and a click event.

Now let's jump to the coding. The code for selecting all the Checkoboxes goes as follows

See the Pen ezgVJV by Arun Biradar (@arunvbiradar) on CodePen.

In the code above
  • I have written a function selectAllNames (), which is called when the checkbox Select all Names is checked that is everytime this checkbox is clicked. I have used onClick () event for this.
  • In the selectAllNames () function, I have targeted each checkboxes by its name attribute. Then by using the for loop I have checked all the checkboxes.

1 comment: