1 line
2.1 KiB
JSON
1 line
2.1 KiB
JSON
{"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<form>\n <input type=\"button\" value=\"Input Button\">\n <input type=\"checkbox\">\n <input type=\"file\">\n <input type=\"hidden\">\n <input type=\"image\">\n <input type=\"password\">\n <input type=\"radio\">\n <input type=\"reset\">\n <input type=\"submit\">\n <input type=\"text\">\n <select>\n <option>Option</option>\n </select>\n <textarea></textarea>\n <button>Button</button>\n</form>\n<div></div>\n"},"longdesc":"\n <p><code>$( \":text\" )</code> allows us to select all <code><input type=\"text\"></code> 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 <code>$( \":text\" )</code> is equivalent to <code>$( \"*:text\" )</code>, so <code>$( \"input:text\" )</code> should be used instead. </p>\n <p><strong>Note:</strong> As of jQuery 1.5.2, <code>:text</code> selects <code>input</code> elements that have no specified <code>type</code> attribute (in which case <code>type=\"text\"</code> is implied). </p>\n <p>This difference in behavior between <code>$( \":text\" )</code> and <code>$( \"[type=text]\" )</code>, can be seen below:</p>\n <pre><code>\n$( \"<input>\" ).is( \"[type=text]\" ); // false\n$( \"<input>\" ).is( \":text\" ); // true\n </code></pre>\n "}],"slug":"text-selector"} |