javascript - Have a customized progress bar in HTML on click of a button -


i novice html coder , have silly issue! want have customized progress bar shows progress once submit clicked. tried using tag of html, did not job me. how can have animation integrated code: http://www.jqueryscript.net/chart-graph/customizable-liquid-bubble-chart-with-jquery-canvas.html#viewsource

i not able figure out in section code has put.

i have tried this,

<!doctype html> <html> <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 >= 100) {       clearinterval(id);     } else {       width++;        elem.style.width = width + '%';        document.getelementbyid("label").innerhtml = width * 1  + '%';     }   } } </script>  </body> </html> 

this doesn't work because dont want progress bar visible before click submit.

in #mybar css property

display:none 

is used , in function again property changed display:inline by

elem.style.display = "inline"; 

here modified code.

  <!doctype html>     <html>     <style>     #myprogress {       position: relative;       width: 100%;       height: 30px;       background-color: #ddd;     }      #mybar {       position: absolute;       width: 10%;       height: 100%;       background-color: #4caf50;       display:none; /*displays none */      }      #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"></div>       </div>     </div>      <br>     <button onclick="move()">click me</button>       <script>     function move() {         var elem = document.getelementbyid("mybar");        var label=document.getelementbyid("label");       var width = 10;       var id = setinterval(frame, 10);       function frame() {         if (width >= 100) {            clearinterval(id);         } else {           width++;            elem.style.display = "inline"; //sets display property default value.              elem.style.width = width + '%';            label.innerhtml = width * 1  + '%';          }       }     }     </script>      </body>     </html> 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -