I want to get a list of names of checkboxes that are selected in a div with certain id. How would I do that using jQuery?
E.g., for this div I want to get array ["c_n_0"; "c_n_3"] or a string "c_n_0;c_n_3"
<div id="checkboxes">
<input id="chkbx_0" type="checkbox" name="c_n_0" checked="checked" />Option 1
<input id="chkbx_1" type="checkbox" name="c_n_1" />Option 2
<input id="chkbx_2" type="checkbox" name="c_n_2" />Option 3
<input id="chkbx_3" type="checkbox" name="c_n_3" checked="checked" />Option 4
</div>
Combination of two previous answers:
var selected = [];
$('#checkboxes input:checked').each(function() {
selected.push($(this).attr('name'));
});