Note that there are some explanatory texts on larger screens.

plurals
  1. POjavascript Change variable gradually over five seconds
    text
    copied!<p>I'm a beginner when it comes to JavaScript. I'm trying to change the value of a progress bar from 100 to 0 in five seconds and I can't get it to work right. I tried this <a href="http://www.onlywebpro.com/2011/09/09/html5-progress-bar/" rel="nofollow">tutorial</a> but there was no way to control the time. I have a <a href="http://jsfiddle.net/Changer098/zfuTp/3/" rel="nofollow">JSFiddle</a> to show what I have. I'd really appreciate any help. My Javascript</p> <pre><code>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; } </code></pre> <p>with my HTML being</p> <pre><code>&lt;body onload="onload()"&gt; &lt;p id="qstn"&gt;&lt;/p&gt; &lt;button class="btn" onclick="checker()"&gt;&lt;span id="a1"&gt;&lt;/span&gt;&lt;/button&gt; &lt;button class="btn" onclick="checker()"&gt;&lt;span id="a2"&gt;&lt;/span&gt;&lt;/button&gt; &lt;button class="btn" onclick="checker()"&gt;&lt;span id="a3"&gt;&lt;/span&gt;&lt;/button&gt; &lt;button class="btn" onclick="checker()"&gt;&lt;span id="a4"&gt;&lt;/span&gt;&lt;/button&gt; &lt;progress value="100" max="100" id="bar"&gt;&lt;/progress&gt; &lt;/body&gt; </code></pre> <p>Again, any help or comments would be greatly appreciated.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload