We help IT Professionals succeed at work.

jQuery: selecting a checkbox by DIV, class and checked status

Brad Bansner
Brad Bansner asked
on
If I have these elements:

<div id="question1">
<input type="checkbox" class="answerCheckbox" value="1" />
</div>

...I can select the box, only if it is checked, like this:

$('#question1 :checkbox:checked')

But, how can I also add the class to make sure any other checkboxes are not selected? I tried this:

$('#question1 .answerCheckbox :checkbox:checked')

...but that did not work. Thanks!
Comment
Watch Question

Commented:
$('#question1 .answerCheckbox:checked')
Brad BansnerWeb Developer

Author

Commented:
Ah, perfect. Thanks!