Contact Us

 Bharat Patel     Feb,08 2017

Check All Checkboxes with JQuery

Very often we need to check or uncheck check boxes at single click using js. If we are using javascript then we have to loop over an array to do so but by below example its been more easy and simple to use it.

Now Using jQuery we can easily do it and thats why i love it. we need only few lines of code for check or uncheck check boxes.

View Demo

 <script src="http://www.google.com/jsapi" type="text/javascript"></script><script>google.load("jquery", "1.3.2");</script><script>jQuery(function(){jQuery('#checkAll').click(function(){var status = jQuery(this).attr('checked');jQuery('input[name=checkOne]').each(function(){this.checked = status;}});});</script>

Checked 1. Name and id of main checkbox.

2. Name of all checkboxes has to be checked.

 

 

I hope you may like it.