Reputation: 21
greetings, I have a div wrapped around a bunch of checkboxes on my form.
<div id="checker">
<input type="checkbox" name="dynamic" id="dynamic" value="dynamic" />
<input type="checkbox" name="dynamic" id="dynamic" value="dynamic" />
<input type="checkbox" name="dynamic" id="dynamic" value="dynamic" />
</div>
... where "dynamic" (above) is coming from a database and I don't know the names or ids. These would be created in a loop of php code - not shown.
Using JQuery, how do I access these checkboxes, so I can loop over them? I'd like to do something like:
$('#checker').children('checkbox').each( function(){ .... });
(I know that is wrong - it's just to show what I'm thinking).
Thoughts? Thanks JohnC
Upvotes: 0
Views: 104
Reputation: 2708
$('#checker').children('input [type="checkbox"]').each(
function(){
....
});
Upvotes: 0
Reputation: 960
Try this:
$('#checker input:checkbox').each(function(){
//do stuff
});
Upvotes: 2
Reputation: 86902
If #checker is the id to your div then
$("div#checker input:checkbox").each(function () { ... });
Upvotes: 0