Q:

Javascript Program to implement Label Progress Bar

0

Program to implement Label Progress Bar using Javascript.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<!DOCTYPE html>
<html>
<style>
#JavaScriptBar {
  width: 100%;
  background-color: #ddd;
}

#ProgressBar {
  width: 10%;
  height: 30px;
  background-color: orange;
  text-align: center;
  line-height: 30px;
  color: black;
}
</style>
<body>

<h1>Progress Bar</h1>

<div id="JavaScriptBar">
  <div id="ProgressBar">10%</div>
</div>

<br>
<button onclick="move()">Click Me</button> 

<script>
function move() {
  var x = document.getElementById("ProgressBar");   
  var width = 10;
  var id = setInterval(frame, 10);
  function frame() {
    if (width >= 100) {
      clearInterval(id);
    } else {
      width++; 
      x.style.width = width + '%'; 
      x.innerHTML = width * 1  + '%';
    }
  }
}
</script>

</body>
</html>

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now