Created
May 8, 2014 07:11
-
-
Save mcxiaoke/714771809cb648253b87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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