Possible duplicate:
Select checkbox group values ββusing jQuery
In HTML, I have a set of flags grouped together by a class. I want to get an array in jQuery containing all the flags that were selected / checked for this class (so that the other flags on the page are ignored).
So, the HTML looks like this:
<input type="checkbox" class="group1" value="18" checked="checked" /> <input type="checkbox" class="group1" value="20" /> <input type="checkbox" class="group1" value="15" /> <input type="checkbox" class="group2" value="14" /> <input type="checkbox" class="group1" value="55" checked="checked" /> <input type="checkbox" class="group1" value="10" checked="checked" /> <input type="checkbox" class="group2" value="77" checked="checked" /> <input type="checkbox" class="group1" value="11" />
Will return the checked / selected group1 flag values ββto an array like this:
var values = [ 18, 55, 10 ];
javascript jquery html
leepowers Jan 20 '10 at 5:05 2010-01-20 05:05
source share