> ## Content Index
> Fetch the complete content index at: https://helpmonks.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Select all checkboxes with JQuery
- URL: https://helpmonks.com/blog/select-all-checkboxes-with-jquery/
- Published: 2012-07-07T00:00:00.000Z
- Updated: 2026-04-04T01:57:47.000Z
- Description: More then once you need to select all checked checkboxes in your web application. With JQuery this is a piece of cake. The following code returns all the che
- Author: Nitai
- Tags: email marketing

More then once you need to select all checked checkboxes in your web application. With JQuery this is a piece of cake. The following code returns all the checked checkbox values in an array AND in a string;

\[javascript\]  
<script type="text/javascript">  
function getchecked(){  
// Get checked values  
var selected = new Array();  
$(‘input\[type=checkbox\]:checked’).each(function() {  
selected.push($(this).val());  
});  
// convert to a string  
var mystring = selected.join(",");  
}  
</script>  
\[/javascript\]

In case you only need to get the checkboxes within a “div” you would something like this:

\[javascript\]  
<script type="text/javascript">  
function getchecked(){  
// Get checked values  
var selected = new Array();  
$(‘#mydiv input:checked’).each(function() {  
selected.push($(this).val());  
});  
// convert to a string  
var mystring = selected.join(",");  
}  
</script>  
\[/javascript\]

and in case you don’t need the values, but only the names you would use:

\[javascript\]  
<script type="text/javascript">  
function getchecked(){  
// Get checked values  
var selected = new Array();  
$(‘input\[type=checkbox\]:checked’).each(function() {  
selected.push($(this).attr(‘name’));  
});  
// convert to a string  
var mystring = selected.join(",");  
}  
</script>  
\[/javascript\]

Now, if you put this is a globally accessible function you will never have to revisit the code and it simply works in your project 🙂 Have fun.