Use $("input[type=text]") Carsten suggested in the comments. (also watch his hints according your syntax)
If you want to work with those elements (for example validating) you can use the .each() function in jquery and work with $(this):
$("input[type=text]").each(function( index ) {
var test = $(this).val();
});
Here some other possibilities to select those inputs:
class
give them all the same class and make the selector like this $(".yourClass")
parent
give the container of all those inputs that you want to select a specific class $(".yourContainerClass input") or more precise $(".yourContainerClass input[type=text]")
attributes
like type you have access to every attribut of the input field like this: $("[attribute='value']") this could be name value or watherver you like
here you have an overview of the attribute selectors according to w3schools:
- [attribute] - ex. $("[href]") - All elements with a href attribute
- [attribute!=value] - ex. $("[href!='default.htm']") - All elements with a href attribute value not equal to "default.htm"
- [attribute$=value] - ex. $("[href$='.jpg']") - All elements with a href attribute value ending with ".jpg"
- [attribute|=value] - ex- $("[title|='Tomorrow']") - All elements with a title attribute value equal to 'Tomorrow', or starting with 'Tomorrow' followed by a hyphen
- [attribute^=value] - ex. $("[title^='Tom']") - All elements with a title attribute value starting with "Tom"
- [attribute~=value] - ex. $("[title~='hello']") - All elements with a title attribute value containing the specific word "hello"
- [attribute*=value] - ex. $("[title*='hello']") - All elements with a title attribute value containing the word "hello"
$("input[type=text]"), also it should beid="first"and notid="#first". Also it should be$('f#irst).text()and not$('first).text()$('.form-control')