我是 JavaScript 的初学者。我试图在五秒钟内将进度条的值从 100 更改为 0,但我无法让它正常工作。我尝试了本教程,但无法控制时间。我有一个JSFiddle来展示我所拥有的。我真的很感激任何帮助。我的 Javascript
var correct = "a1";
function onload()
{
var question1 = "Who was the first president?";
var answers = {
"a1":"George Washington",
"a2":"John Adams",
"a3":"Bill Clinton",
"a4":"Richard Nixon"};
document.getElementById("qstn").innerHTML=question1;
document.getElementById("a1").innerHTML=answers.a1;
document.getElementById("a2").innerHTML=answers.a2;
document.getElementById("a3").innerHTML=answers.a3;
document.getElementById("a4").innerHTML=answers.a4;
var bar = document.getElementById("bar").value;
}
我的 HTML 是
<body onload="onload()">
<p id="qstn"></p>
<button class="btn" onclick="checker()"><span id="a1"></span></button>
<button class="btn" onclick="checker()"><span id="a2"></span></button>
<button class="btn" onclick="checker()"><span id="a3"></span></button>
<button class="btn" onclick="checker()"><span id="a4"></span></button>
<progress value="100" max="100" id="bar"></progress>
</body>
再次,任何帮助或意见将不胜感激。