title: How to animate a simple progress bar using JavaScript?
body: <p>Here is a loading bar script in CSS... I want to animate it using a Javascript function... But I have no idea where to start?</p>
  
  <p>Here is the code:</p>
  
  <p>I have tried this CSS code to animate it but using CSS:</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-css lang-css prettyprint-override"><code>* {
    margin: 0px;
    padding: 0px;
    border: 0px;
    font-family: sans-serif;
    cursor: default;
    -webkit-user-select: none;
    -ms-user-select: none;
    -o-user-select: none;
    user-select: none;
  }
  
  body {
    background: #ffff;
  }
  
  #pb {
    background: #transparent;
    width: 250px;
    height: 38px;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -19px;
    margin-left: -125px;
    border-radius: 8px;
    padding: 3px;
    overflow: hidden;
    text-align: center;
  }
  
  #progress {
    height: 38px;
    width: 250px;
    background-color: #0080FF;
    border-radius: 6px;
    background: #6db3f2;
    background: -moz-linear-gradient(top, #6db3f2 0%, #54a3ee 50%, #3690f0 51%, #1e69de 100%);
    /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #6db3f2), color-stop(50%, #54a3ee), color-stop(51%, #3690f0), color-stop(100%, #1e69de));
    /* Chrome,Safari4+ */
  }
  
  #done:active {
    -webkit-box-shadow: inset 0px 0px 18px rgba(0, 0, 0, 0.4);
    box-shadow: inset 0px 0px 18px rgba(0, 0, 0, 0.4);
    border-radius: 6px;
  }
  
  #done {
    text-align: center;
    line-height: 38px;
    font-size: 14px;
    font-weight: bold;
    color: #EEE;
    height: 38px;
    width: 250px;
    text-shadow: 0px -1px 0px rgba(0, 0, 0, 0.2);
    cursor: pointer;
  }
  
  #pb:hover #progress {
    transition: all 10.3s;
    width: 10px;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="pb"&gt;
    &lt;div id="progress"&gt;
      &lt;div id="done"&gt;Loading...&lt;/div&gt;
    &lt;/div&gt;
    Done!
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>But I want a Javascript function to animate the progress bar in 10 seconds.</p>
  
  <p>Any help would be greatly appreciated</p>