<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> </head> <body> <div> <input type="radio" id="radio1" name="some-radio-group" /> <input type="radio" id="radio2" name="some-radio-group" checked="checked" /> </div> <div> <input type="button" id="btn1" value="btn1" /> </div> <script> var checkedValue; var elements = document.getElementsByTagName("input"); for (var i = 0; i < elements.length; i++) { if (elements[i].type === "radio" && elements[i].name === "some-radio-group" && elements[i].checked) { checkedValue = elements[i].value; break; } } </script> </body> </html>
注:被选中的值是:“on” ,而不是 true