aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

jQuery - How to Select Deselect All Checkboxes with Name

Sep 24, 2013

Here I will explain how to use jQuery to select deselect all checkboxes or check uncheck all checkboxes using jQuery.

To implement this we need to write the code like as shown below

<html xmlns="">
<title>jQuery Select Deselect all Checkboxes</title>
<script src="" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('input[name="chkUser"]').click(function () {
if ($('input[name="chkUser"]').length == $('input[name="chkUser"]:checked').length) {
$('input:checkbox[name="chkAll"]').attr("checked", "checked");
else {
$('input:checkbox[name="chkAll"]').click(function () {
var slvals = []
if ($(this).is(':checked')) {
$('input[name="chkUser"]').attr("checked", true);
else {
$('input[name="chkUser"]').attr("checked", false);
slvals = null;
<style type="text/css">
<li><label><input type="checkbox" name="chkAll" value="All"/>
Select All
<li><label><input type="checkbox" name="chkUser" value="3930"/>Suresh</label></li>
<li><label><input type="checkbox" name="chkUser" value="4049"/>Rhoini</label></li>
<li><label><input type="checkbox" name="chkUser" value="4076"/>Mahesh</label></li>
<li><label><input type="checkbox" name="chkUser" value="4086"/>Mahendra</label></li>
<li><label><input type="checkbox" name="chkUser" value="4087"/>Madhav</label></li>
<li><label><input type="checkbox" name="chkUser" value="4116"/>Honey</label></li>
<li><label><input type="checkbox" name="chkUser" value="4143"/>Sateesh</label></li>
<li><label><input type="checkbox" name="chkUser" value="4296"/>Praveen</label></li>

Note: if you are using checkbox controls then you need to replace

$('input:checkbox[name="chkAll"]') with ('[id$= chkAll]')

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

Other Related Posts

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.