This might be the easiest question of the day.
i have a groups of checkboxes with similar id's (all starting with someid_
like someid_0
,someid_1
..)
i want to get all checked
checkboxes.
I have tried $('input:checkbox[id^="someid_"]:checked')
but it's not working?
this code is working check demo
http://jsfiddle.net/csTpG/
Markup
<input type="checkbox" id="someid_1" checked/>
<input type="checkbox" id="someid_2" checked/>
<input type="checkbox" id="someid_3" checked/>
<input type="checkbox" id="someid_4"/>
jQuery
var n = $('input:checkbox[id^="someid_"]:checked').length;
alert(n); // count of checked checkboxes
$('input:checkbox[id^="someid_"]:checked').each(function(){
alert($(this).attr("id"));});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With