Read multiple jQuery.val() into array

Viewed 13884

I have some code that looks like this that works just fine:

var info = [];
for (i = 0; i < 10; i++)
{
     info[i] = $('#info_' + i).val();
}

The problem is that this pattern is very common in my application with some minor variations. What i would like to do is to make this into a oneliner something like this where info becomes an array:

var info = $('[id^="info_"]').each().val();
3 Answers
Related