/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<div id="progress" style="background: green; width: 0;"> </div> <p><a href="#" onclick="progress(); return false;">start</a></p> function progress() { var loadingbar = document.getElementById("progress"); var width = parseInt(loadingbar.style.width); width++; loadingbar.style.width = width + "px"; if (width < 300) { setTimeout(progress, 10); } }
URL: http://jsfiddle.net/YR9fd/4/