![](/img/trans.png)
[英]I want to iterate the Table using .childNodes, then find the <B> tag. My code doesn't work!
[英]I want to reset every radiobutton to unchecked, but my code doesn't work
对于 javascript 课程,我正在尝试完成挑战。 单击按钮后,我想取消选中每个选中的单选按钮。 下面是我的代码:
let result = 0;
function checkResult() {
if (document.getElementById("quiz1a").checked == true) {
result++;
}
if (document.getElementById("quiz2c").checked == true) {
result++;
}
if (document.getElementById("quiz3a").checked == true) {
result++;
}
if (document.getElementById("quiz4a").checked == true) {
result++;
}
document.querySelectorAll('input[type="radio"]').checked = false;
console.log(result);
result = 0;
}
document.querySelectorAll('input[type="radio"]')
返回一个数组。 您应该使用forEach
迭代其元素。
由于这是一门课程,我不会为你拼写出来;)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.