title: Progress bar with duration and percentage
body: <p>I want to create a progress bar that has a duration ( the time that it takes to finish the animation) and a percentage.</p>
  
  <p>So I want this progress bar to take 3000ms to finish ( to get to 100%):</p>
  
  <p>So far : </p>
  
  <pre><code>  &lt;div id="box"&gt;&lt;/div&gt;
  
    &lt;script&gt;
       function start(){
            var duration = 5000; // it should finish in 5 seconds !
           var max = 100;
           var i = 0 ;
           var interval = setInterval(function(){
              i++;
              offset  = (max*i)/duration;
              console.log(offset);
              $("#box").css("width", offset + "px");
              $("#box").text(parseInt(offset) + "%");
              if(i&gt;=duration){
                  alert("done "+i);
                  clearInterval(interval);
              }
          }, 1);
  
  
        }
    &lt;/script&gt;
  </code></pre>
  
  <p>It works but it takes way longer that 5000ms .</p>
  
  <p>I've also added Jquery tag because I don't care if I do this with javascript or jquery</p>
  
  <p>Thanks guys.</p>