סלקטור radio
תיאור: תואם לכל האלמנטים מסוג radio.
jQuery(':radio')
הוספה בגרסה: 1.0
$(':radio') שווה ל- $('[type=radio]').
כמו עם סלקטורים פסאודו מחלקה אחרים (אלו מתחילים עם ":") מומלץ להקדים את זה עם שם התג או סלקטור אחר, אחרת, מרומז סלקטור אוניברסלי ("*").
במילים אחרות, $(':radio')
החשוף שווה ל-
$('*:radio'), לכן, יש להשתמש ב- $('input:radio')
במקום זה.
כדי לבחור רשימת כפתורי רדיו קשורים, אתם יכולים להשתמש ב:
$('input[name=gender]:radio')
דוגמאות
דוגמה 1
מחפש כל האלמנטים מסוג radio.קוד מלא:
<!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-latest.js"></script> <script> $(document).ready(function(){ var input = $("form input:radio").wrap('<span></span>').parent().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" name="asdf" /> <input type="radio" name="asdf" /> <input type="reset" /> <input type="submit" /> <input type="text" /> <select><option>Option<option/></select> <textarea></textarea> <button>Button</button> </form> <div> </div> </body> </html>
האם מידע זה היה מועיל?

