Getting and using values obtained from multiple text boxes via JQuery

Your sample is only returning the value in the first item in the array. You need to iterate through the array, and you can use the each. The jQuery selector syntax returns a jQuery object that contains matched objects as an array.

You can use the other variation of $.each, too, like so...

var test_arr = $("input[name*='man']");
$.each(test_arr, function(i, item) {  //i=index, item=element in array
    alert($(item).val());
});

Since the jQuery object that's returned is an array of matched elements, you can also use a traditional for loop...

//you can also use a traditional for loop
for(var i=0;i<test_arr.length;i++) {
    alert($(test_arr[i]).val());
}

Tags:

Jquery