Basic JavaScript Progressbar Animation


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <div id="progress" style="background: green; width: 0;">&nbsp;</div>
  2. <p><a href="#" onclick="progress(); return false;">start</a></p>
  3.  
  4. function progress() {
  5. var loadingbar = document.getElementById("progress");
  6. var width = parseInt(loadingbar.style.width);
  7. width++;
  8. loadingbar.style.width = width + "px";
  9. if (width < 300) {
  10. setTimeout(progress, 10);
  11. }
  12. }

URL: http://jsfiddle.net/YR9fd/4/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.