checkbox - How to Grab multiple values from checkboxes with Jquery -
i have form
<form class='lostkittieform'> <label class="kittiecolor"><input type="checkbox" value="black">black</label> <label class="kittiecolor"><input type="checkbox" value="brown">brown</label> <label class="kittiecolor"><input type="checkbox" value="white">white</label> <label class="kittiecolor"><input type="checkbox" value="gray">gray</label> <label class="kittiecolor"><input type="checkbox" value="orange">orange</label> <label class="kittiecolor"><input type="checkbox" value="multicolored">multicolored</label> <input type="submit"> </form>
my jquery code trying grab values checked reason it's grabbing 1 , "black"
kittie.color = $(".lostkittieform input[type='checkbox']").val();
thanks in advance!
$("checkbox").each(function(e){ var checkval = $(this).val(); });
or
$('.lostkittieform input:checked').each(function() { var checkval = $(this).val(); }); // return value "checked" checkboxes
the loop run each checkbox , can value of every checkbox in checkval variable 1 one .
for documentation of .each() go .
Comments
Post a Comment