I want to iterate over checkboxes div and determine if checkbox1,checkbox2,checkbox3 are checked
// iterate over checkboxes
$('#register_students').click(function() {
$("div.checkboxes").each(function() {
var student = $(this).attr('data');
var checkbox1 = ???
var checkbox2 = ???
var checkbox3 = ???
});
return false;
});
<td>
<div class='checkboxes' data=8255>
<INPUT type="checkbox" value="36" class="checkbox1">
<INPUT type="checkbox" value="14" class="checkbox2">
</div>
</td>
<td>
<div class='checkboxes' data=8244>
<INPUT type="checkbox" value="36" class="checkbox1">
<INPUT type="checkbox" value="14" class="checkbox2">
<INPUT type="checkbox" value="14" class="checkbox3">
</div>
</td>
You’re interating over the
divscontaining the checkboxes, so you need tofindyour checkboxes.(You should also probably cache
$(this)to avoid multiple calls):The three checkbox lines will each return a boolean indicating whther the checkbox in the current div is checked.