โค้ดประมาณนี้ครับ
<!doctype html> <html> <head> <meta charset="utf-8"> <script src="jquery-2.1.1.min.js"></script> <script> $(document).ready(function(){ $("button").on("click",function(){ var v = $("input[type=radio]:checked").val(); alert(v); }); }); </script> </head> <body> <input type="radio" name="sex" value="Male" checked="checked">Male<br/> <input type="radio" name="sex" value="Female">Female<br/> <button>OK</button> </body> </html>
No comments:
Post a Comment