[jQuery] Plucking values from multiple inputs at once
<div>From what I undstand, jQuery#val() returns the value of the first matched element.</div><div>
</div><div>Sample HTML:</div><div>
</div><div><input type="hidden" name="test[]" value="foo" /></div>
<div><input type="hidden" name="test[]" value="bar" />
</div><div>
</div><div>$('input[type=hidden][name="test\[\]"]').val(); // returns "foo"</div><div>
</div><div>Is there an easy way to get an array of values from <span class="Apple-style-span" style="font-weight: bold;">all</span> of the elements that matched the selector?</div><div>
</div><div>So far I have this, but I'd like to reduce this to a jQuery method if there is one:</div>
<div>
</div><div>var values = [];</div><div>$('input[type=hidden][name="test\[\]"]').each(function()
</div><div>{</div><div> values.push($(this).val());</div><div>});</div><div>
</div><div>console.log(values); // [foo, bar]
</div><br clear="all">-Hector