>From what I undstand, jQuery#val() returns the value of the first matched
element.

Sample HTML:

<input type="hidden" name="test[]" value="foo" />
<input type="hidden" name="test[]" value="bar" />

$('input[type=hidden][name="test\[\]"]').val(); // returns "foo"

Is there an easy way to get an array of values from all of the elements that
matched the selector?

So far I have this, but I'd like to reduce this to a jQuery method if there
is one:

var values = [];
$('input[type=hidden][name="test\[\]"]').each(function()
{
    values.push($(this).val());
});

console.log(values); // [foo, bar]

-Hector

Reply via email to