这个 java 脚本应该单击按钮(制作动画幻灯片)问题是我无法管理单击按钮的代码,而且我找不到错误,似乎正在运行
<!DOCTYPE html>
<html>
<script type="text/javascript">
var seconds = 0;
setInterval(setTime, 1000);
function setTime() {
seconds++;
if (seconds == 5) {
document.getElementById('i2').value = true;
} else if (seconds == 10) {
document.getElementById('i3').value = true;
} else if (seconds == 15) {
document.getElementById('i4').value = true;
} else if(seconds == 20) {
document.getElementById('i1').value = true;
seconds == 0;
}
}
</script>
<div class="slideshow" onload="setTime()">
<input type="radio" id="i1" name="images" checked/>
<input type="radio" id="i2" name="images" />
<input type="radio" id="i3" name="images" />
<input type="radio" id="i4" name="images" />
</div>
</html>
我尝试了 .checked
.click()
.value
,它不起作用,有些东西搞乱了 Action ,但我还是想不通弄清楚它是什么。
最佳答案
值
是如果单选按钮被选中时将与表单数据一起提交的值。
如果要将其状态从未选中更改为已选中,则需要修改 checked
属性。
var seconds = 0;
setInterval(setTime, 1000);
function setTime() {
seconds++;
if (seconds == 5) {
document.getElementById('i2').checked = true;
} else if (seconds == 10) {
document.getElementById('i3').checked = true;
} else if (seconds == 15) {
document.getElementById('i4').checked = true;
} else if (seconds == 20) {
document.getElementById('i1').checked = true;
seconds == 0;
}
}
<input type="radio" id="i1" name="images" checked/>
<input type="radio" id="i2" name="images" />
<input type="radio" id="i3" name="images" />
<input type="radio" id="i4" name="images" />
关于javascript - 单击单选类型按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53188351/