title: Auto incrementing a counter in JavaScript
body: <p>I want to animate a counter from 0 to a given value automatically on page load. Recently I found one but it works with button click.</p>
  
  <pre><code>var amount=parseInt($('#amount').val());
  var i = parseInt($('#count').val());
  var tim;
  
  function run(){
      tim = setInterval(function(){
          if(i&gt;=amount){clearInterval(tim); return;}
          $('#count').val(++i);
      },100);        
  }
  
  $('#runner').click(function(){         
      run();
  });
  </code></pre>
  
  <p>SEE >> <a href="http://jsfiddle.net/LNE48/2/" rel="nofollow"><strong>JS fiddle DEMO</strong></a></p>
  
  <p>Also I want to add a reset button in it which will run it again from 0 on every click.</p>