<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css" media="all"> </style> <title>js获取单选框的值value</title> </head> <body> <div > <input type="radio" name="bday" value="苹果" onclick="submit1()"/>苹果 <input type="radio" name="bday" value="香蕉" onclick="submit1()"/>香蕉 <input type="radio" name="bday" value="西瓜" onclick="submit1()"/>西瓜 </div> </body> <script > var dr=document.getElementsByName("bday"); function submit1(){ for(i=0;i<dr.length;i++){ if(dr[i].checked){ alert(dr[i].value); break; } } } //reverse submit1.reverseSelect=function(){ for(i=0;i<drc.length;i++){ if(dr[i].checked){ dr[i].checked=false; }else{ dr[i].checked=true; } } } </script> </html>