Skip to content

Instantly share code, notes, and snippets.

@mlent
Last active June 2, 2016 21:34
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 mlent/1dcc06cb875089ed74eea6c4f00b9a5e to your computer and use it in GitHub Desktop.
Save mlent/1dcc06cb875089ed74eea6c4f00b9a5e to your computer and use it in GitHub Desktop.
<script>
var btn = document.getElementById('myButton');
btn.addEventListener('click', loadProgress);
function loadProgress() {
console.log('Button clicked!');
var progressBar = document.getElementsByClassName('progress-bar')[0];
var interval = 30;
var currentValue = 0;
for (var i = 0; i < 100; i += interval) {
console.log('Setting interval', i)
setTimeout(function() {
currentValue += i;
console.log('Setting progress width to:', currentValue, '%');
progressBar.setAttribute('style', 'width: ' + currentValue + '%');
}, i);
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment