I want to get all fields that are located in a single class name, for example my code like.
If you want all the values into an array, you can do this:
var texts= $(".test .text-field").map(function() {
return $(this).val();
}).get();
From cwallenpoole's answer following should work
$.each( $(".test input[type=\"text\"]"), function(index, ele){
alert( ele.val());
});
Have you tried this:
$(".test input[type=\"text\"]")
Try this:
$(".test .text-field")
EDIT:
To get values try this:
$(".test .text-field").each(function() {
alert($(this).val());
});
Here's another method to obtain an array of the input values:
Array.from($('.test .text-field').get(), e => e.value)
Or alternatively:
[].map.call($('.test .text-field').get(), e => e.value)