Can anyone help with the following, it doesn't return any checked checkboxes.. Am i doing somethign wrong?
I have
$("input[type=checkbox][checked] .type-element").each(
function(index) {
alert('checked' + index);
}
);
here is part of my html ( i have a number of them all as type-container)
<div id="type-1" class="type-container">
<div class="type-description">
test
</div>
<input id="11" class="type-element" type="checkbox"/>
</div>
Just do:
$(":checked")...
for checked checkboxes. Also you have an extraneous space in your expression before ".type-element". If you want to make sure the checked checkboxes have that class use:
$(":checked.type-element")...
not ":checked .type-element"
(note the space).
So the end result is:
$(":checked.type-element").each(
function(index) {
alert('checked' + index);
}
);
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