JavaScript Progress Bar

HTML
<div id="myProgress"> <div id="myBar"></div> </div> <!-- (c) https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_progressbar_3 -->
CSS
#myProgress { width: 100%; background-color: #ddd; } #myBar { width: 0%; height: 100vh; background-color: #4CAF50; }
JAVASCRIPT
$(window).load(function() { move(); }); function move() { var time = 20; var elem = document.getElementById("myBar"); var width = 1; var id = setInterval(frame, time); function frame() { if (width >= 100) { clearInterval(id); } else { width++; elem.style.width = width + '%'; } } }
Expand for more options Login