Check uncheck all checkboxes with jQuery

Use jQuery prop function to check or uncheck form check boxes.
Its javascript version is available in another article named Check uncheck all checkboxes with javascript

The Html Form

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">  </script>
  <script type="text/javascript">
  $(document).ready(function(e) {
    $('#checkAll').click(function(){
       $('input:checkbox').prop('checked', this.checked);  
    });
  });
  </script>
  
  <form name="checkForm">
  <input type="checkbox" id="checkAll">Check/Uncheck All
  <input type="checkbox" name="one" value ="one">One
  <input type="checkbox" name="two" value ="two">Two
  <input type="checkbox" name="three" value ="three">Three
  <input type="checkbox" name="four" value ="four">Four
  <input type="checkbox" name="five" value ="five">Five
  </form>

The Example

Check/Uncheck All
One
Two
Three
Four
Five
Check uncheck all checkboxes with jQuery Check uncheck all checkboxes with jQuery Reviewed by Altaf Hussain on 1:59 PM Rating: 5

No comments:

Altaf Web. Powered by Blogger.