Last active
April 1, 2016 15:23
-
-
Save talha08/73f86ca7dced32802ddf3e7a315ee301 to your computer and use it in GitHub Desktop.
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> | |
<title>Bootstrap Example</title> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> | |
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> | |
</head> | |
<style> | |
#myProgress { | |
position: relative; | |
width: 100%; | |
height: 30px; | |
background-color: #ddd; | |
} | |
#myBar { | |
position: absolute; | |
width: 10%; | |
height: 100%; | |
background-color: #4CAF50; | |
} | |
#label { | |
text-align: center; | |
line-height: 30px; | |
color: white; | |
} | |
</style> | |
<body> | |
<h1>JavaScript Progress Bar</h1> | |
<div id="myProgress"> | |
<div id="myBar"> | |
<div id="label">10%</div> | |
</div> | |
</div> | |
<br> | |
<button onclick="move()">Click Me</button> | |
<script> | |
function move() { | |
var elem = document.getElementById("myBar"); | |
var width = 10; | |
var id = setInterval(frame, 10); | |
function frame() { | |
if (width >= 50) { | |
clearInterval(id); | |
} else { | |
width++; | |
elem.style.width = width + '%'; | |
document.getElementById("label").innerHTML = width * 1 + '%'; | |
} | |
} | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment