【发布时间】:2020-07-05 16:59:52
【问题描述】:
我目前正在尝试建立一个站点,该站点将具有可根据计时器切换的交替图像。我有一个功能设置的原型,但我想做一些额外的事情。我想要它,以便当我单击按钮时图像会自动更改。我设置了这个,但是现在我遇到了用户可能没有足够的时间来查看它的问题,所以我希望能够设置计时器,以便在单击按钮时它会回到设置的时间图像发生变化时,用户可以获得整整 30 秒的时间。有没有办法做到这一点?
点击按钮时基本上时间 = 30 或 60
time = 60;
interval = setInterval(function() {
time--;
document.getElementById('Label1').innerHTML =
"" + time + " seconds"
if (time == 0) {
document.getElementById('downtown').click ();
time = 60;
} else if (time == 30)
document.getElementById('rockBottom').click();
}, 1000)
【问题讨论】:
-
这个
when the button is clicked it will go back to the set time at which the image changes, so users get a full 30 seconds是什么意思?在剩余的 42 秒内单击说按钮。在您的情况下,图像正在发生变化。那么你的情况下一步是什么?
标签: javascript html button timer transition