Last active
September 21, 2017 02:41
-
-
Save swathiPaipalle/de6f31b7281216308a04d917919ac468 to your computer and use it in GitHub Desktop.
Progress bar using Javascript // source https://jsbin.com/zuqukug/25
This file contains hidden or 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 name="description" content="Add num dynamically"> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
.progress-bar { | |
width: 100%; | |
border: solid 1px yellow; | |
background: #fff; | |
} | |
.progress-bar-fill { | |
height: 15px; | |
background: #659cef; | |
width:10%; | |
/*transition: width 250ms ease-in-out;*/ | |
transition: width 1s ease-in-out; | |
} | |
</style> | |
</head> | |
<body class="container"> | |
<div class="progress-bar"> | |
<div id='progress' class="progress-bar-fill" ></div> | |
</div> | |
<script id="jsbin-javascript"> | |
function add(arr){ | |
var add1 = arr.reduce(function(a,b){ | |
return a+b; | |
}); | |
return add1; | |
} | |
var arr = [1,2,3,4,5]; | |
//console.log(add(arr)); | |
// $('.progress-bar-fill').delay(1000).queue(function () { | |
// $(this).css('width', '100%') | |
// }); | |
var bar = document.getElementById('progress'); | |
var width=0; | |
var progress = setInterval(function(){ | |
width+=10; | |
bar.style.width=width+'%'; | |
if(width>100){ | |
clearInterval(progress); | |
} | |
}, 1000); | |
</script> | |
<script id="jsbin-source-css" type="text/css">.progress-bar { | |
width: 100%; | |
border: solid 1px yellow; | |
background: #fff; | |
} | |
.progress-bar-fill { | |
height: 15px; | |
background: #659cef; | |
width:10%; | |
/*transition: width 250ms ease-in-out;*/ | |
transition: width 1s ease-in-out; | |
}</script> | |
<script id="jsbin-source-javascript" type="text/javascript"> | |
function add(arr){ | |
var add1 = arr.reduce(function(a,b){ | |
return a+b; | |
}); | |
return add1; | |
} | |
var arr = [1,2,3,4,5]; | |
//console.log(add(arr)); | |
// $('.progress-bar-fill').delay(1000).queue(function () { | |
// $(this).css('width', '100%') | |
// }); | |
var bar = document.getElementById('progress'); | |
var width=0; | |
var progress = setInterval(function(){ | |
width+=10; | |
bar.style.width=width+'%'; | |
if(width>100){ | |
clearInterval(progress); | |
} | |
}, 1000); | |
</script></body> | |
</html> |
This file contains hidden or 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
.progress-bar { | |
width: 100%; | |
border: solid 1px yellow; | |
background: #fff; | |
} | |
.progress-bar-fill { | |
height: 15px; | |
background: #659cef; | |
width:10%; | |
/*transition: width 250ms ease-in-out;*/ | |
transition: width 1s ease-in-out; | |
} |
This file contains hidden or 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
function add(arr){ | |
var add1 = arr.reduce(function(a,b){ | |
return a+b; | |
}); | |
return add1; | |
} | |
var arr = [1,2,3,4,5]; | |
//console.log(add(arr)); | |
// $('.progress-bar-fill').delay(1000).queue(function () { | |
// $(this).css('width', '100%') | |
// }); | |
var bar = document.getElementById('progress'); | |
var width=0; | |
var progress = setInterval(function(){ | |
width+=10; | |
bar.style.width=width+'%'; | |
if(width>100){ | |
clearInterval(progress); | |
} | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment