{"name":"text","type":"selector","title":":text Selector","deprecated":null,"removed":null,"desc":"Selects all elements of type text.","categories":["selectors/form-selectors","selectors/jquery-selector-extensions","version/1.0"],"entries":[{"return":"","signatures":{"added":"1.0"},"examples":{"desc":"Finds all text inputs.","code":"\nvar input = $( \"form input:text\" ).css({\n background: \"yellow\",\n border: \"3px red solid\"\n});\n\n$( \"div\" )\n .text( \"For this type jQuery found \" + input.length + \".\" )\n .css( \"color\", \"red\" );\n\n// Prevent form submission\n$( \"form\" ).submit(function( event ) {\n event.preventDefault();\n});\n","css":"\n textarea {\n height: 25px;\n }\n","html":"\n
\n\n"},"longdesc":"\n$( \":text\" ) allows us to select all <input type=\"text\"> elements. As with other pseudo-class selectors (those that begin with a \":\") it is recommended to precede it with a tag name or some other selector; otherwise, the universal selector ( \"*\" ) is implied. In other words, the bare $( \":text\" ) is equivalent to $( \"*:text\" ), so $( \"input:text\" ) should be used instead.
Note: As of jQuery 1.5.2, :text selects input elements that have no specified type attribute (in which case type=\"text\" is implied).
This difference in behavior between $( \":text\" ) and $( \"[type=text]\" ), can be seen below:
\n$( \"<input>\" ).is( \"[type=text]\" ); // false\n$( \"<input>\" ).is( \":text\" ); // true\n \n "}],"slug":"text-selector"}