我认为这会起作用,但如果为空,它不会返回 false。有什么建议么?
var radioButtons = document.getElementsByName("Vehicle");
for (var i = 0; i < radioButtons.length; i++) {
if (radioButtons[i].checked) {
console.log("radioButton " + i + ": " + radioButtons[i].value);
}
}
我认为这会起作用,但如果为空,它不会返回 false。有什么建议么?
var radioButtons = document.getElementsByName("Vehicle");
for (var i = 0; i < radioButtons.length; i++) {
if (radioButtons[i].checked) {
console.log("radioButton " + i + ": " + radioButtons[i].value);
}
}