Skip to content

Instantly share code, notes, and snippets.

@mcxiaoke
Created May 8, 2014 07:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcxiaoke/714771809cb648253b87 to your computer and use it in GitHub Desktop.
Save mcxiaoke/714771809cb648253b87 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<style>
#progress-holder{width:200px;height:200px;background:green}
#progress{width:100%;height:100%;background:gray;}
</style>
<div id="progress-holder">
<div id="progress"></div>
</div>
<button id="button">Click me</button>
<script>
var tid=-1;
var perc=100;
var progress = document.getElementById('progress');
function updateValue() {
console.log("update value, perc="+perc);
perc-=5;
if(perc<0){
perc=0;
}
progress.style.height = perc+'%';
}
document.getElementById('button').onclick = function() {
tid=window.setInterval(updateValue,50);
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment