I need to loop through a div full of an unknown number of checkboxes and get back the values of the checkboxes that are checked, how do I do this with jQuery? I guess it should happen onchange of any of the checkboxes.
Just do:
<div id="blah"> 
  <input type="checkbox" class="mycheckbox" />
  <input type="checkbox" class="mycheckbox" />
  <input type="checkbox" class="mycheckbox" />
</div>
$("#blah .mycheckbox").each(function(){
  alert(this + "is a checkbox!");
});
                        Try:
<div id="blah"> 
  <input type="checkbox" class="mycheckbox" />
  <input type="checkbox" class="mycheckbox" />
  <input type="checkbox" class="mycheckbox" />
</div>
$("#blah .mycheckbox:checked").each(function(){
  alert($(this).attr("value"));
});
                        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