סלקטור text
תיאור: תואם לכל האלמנטים מסוג טקסט.
jQuery(':text')
הוספה בגרסה: 1.0
$(':text') שווה ל- $('[type=text]')
וכך בוחר את כל האלמנטים
<input type="text">.
כמו עם סלקטורים פסאודו מחלקה אחרים
(אלו מתחילים עם ":")
מומלץ להקדים את זה עם שם התג או סלקטור אחר,
אחרת, מרומז סלקטור אוניברסלי
("*").
במילים אחרות,
$(':text')
החשוף שווה ל-
$('*:text'),
לכן, יש להשתמש ב-
$('input:text')
במקום זה.
דוגמאות
מחפש כל האלמנטים מסוג text.קוד מלא:
<!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-latest.js"></script> <script> $(document).ready(function(){ var input = $("form input:text").css({background:"yellow", border:"3px red solid"}); $("div").text("For this type jQuery found " + input.length + ".") .css("color", "red"); $("form").submit(function () { return false; }); // so it won't submit }); </script> <style> textarea { height:25px; } </style> </head> <body> <form> <input type="button" value="Input Button"/> <input type="checkbox" /> <input type="file" /> <input type="hidden" /> <input type="image" /> <input type="password" /> <input type="radio" /> <input type="reset" /> <input type="submit" /> <input type="text" /> <select><option>Option<option/></select> <textarea></textarea> <button>Button</button> </form> <div> </div> </body> </html>
האם מידע זה היה מועיל?

