0
我想不通为什么我的JavaScript不工作。我试图在选择单选按钮时显示确认,如果用户同意确认提醒,请选择另一个单选按钮。单选按钮JavaScript如果语句不工作
alertFunction: function() {
var radio = document.getElementById("radio");
if (radio.checked == true) {
//select other radio button
if (confirm('Would you like to select other radio?')) {
document.getElementById("otherRadio").checked = true;
} else {
// Do nothing!
}
}
}
继承人jsfiddle
工作对我来说,如果收音机被选中,在页面加载? https://jsfiddle.net/sorr2jzm/2/ – sinisake
如果在收取页面时未检查收音机,我如何才能使其工作?我只想在用户检查收音机时显示警报。 –
检查浏览器开发工具的控制台选项卡上的错误消息。检查你做的查询(document.getElement ...)是否返回undefined(即如果元素存在于文档中) – 2016-05-23 18:01:34