Skip to content

Instantly share code, notes, and snippets.

@yehchge
Last active February 29, 2016 06:51
Show Gist options
  • Save yehchge/9fb8f0679b74b2bcc01d to your computer and use it in GitHub Desktop.
Save yehchge/9fb8f0679b74b2bcc01d to your computer and use it in GitHub Desktop.
Javascript 進度條
<html>
<head>
<script type="text/javascript">
var bar_width = 200;
function progress() {
var node = document.getElementById('progress');
var w = node.style.width.match(/\d+/);
if (w == bar_width) {
w = 0;
}
node.style.width = parseInt(w) + 5 + 'px';
}
</script>
</head>
<body onload="var progress_run_id = setInterval(progress, 250);">
<div style="border: 1px solid black; width:200px; height:5px;">
<div id="progress" style="height:5px; width:0px; background-color:red;"/>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment