Select/Deselect all check boxes using jquery

No comments
Check/Uncheck check boxes is a very basic requirement in tabular data representation. Almost all the core php web application which i have created, needed to add functionality for deleting/editing multiple rows at a time.
That's why in this tutorial, I going to share this very small Jquery code with you so that you could also use this functionality in your web application.


The HTML Code:

<input type="checkbox" id="checkAll">Check All
<hr />
<input type="checkbox" id="checkItem">checkbox 1 <br/>
<input type="checkbox" id="checkItem">checkbox 2 <br/>
<input type="checkbox" id="checkItem">checkbox 3 <br/>
<input type="checkbox" id="checkItem">checkbox 4 <br/>
<input type="checkbox" id="checkItem">checkbox 5

The Jquery Code:

<script type="text/javascript">
 $("#checkAll").click(function () {
     $('input:checkbox').not(this).prop('checked', this.checked);
 });
</script>

I hope this small tutorial will help you. If you have any problem while integrating this code, please do let me in the comment box below. I would love to help you.

No comments :

Post a Comment