title: Making script in html run automatically?
body: <p>I am new to HTML and javascript. I have below code with me which runs progress bar on clicking button. Can anybody help me below points :-
  1) Making it independent of button. It should start executing automatically.
  2) Can I introduce delay in executing. eg start executing after 10sec
  3) Can i change color once progress in 100% to yellow?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function move() {
    var elem = document.getElementById("myBar");
    var width = 5;
    var id = setInterval(frame, 100);
  
    function frame() {
      if (width &gt;= 100) {
        clearInterval(id);
      } else {
        width++;
        elem.style.width = width + '%';
        elem.innerHTML = width * 1 + '%';
      }
    }
  }</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>#myProgress {
    width: 40%;
    background-color: #ddd;
  }
  
  #myBar {
    width: 0%;
    height: 30px;
    background-color: #4CAF50;
    text-align: center;
    line-height: 30px;
    color: white;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="myProgress"&gt;
    &lt;div id="myBar"&gt;0%&lt;/div&gt;
  &lt;/div&gt;
  
  &lt;br&gt;
  &lt;button onclick="move()"&gt;Click Me&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>