title: How to display running counter in Javascript?
body: <p>I have a table cell that contains a numerical value. </p>
  
  <p>When changing the value, I want to create an effect where the counter moves up (or down) in 100 steps until reaching the new value.</p>
  
  <p>I've tried something like the following (with the help of jQuery):
  <code></p>
  
  <pre>
  function update(element,newValue)
  {
    var oldValue = parseFloat($(element).text());
    var diff = (newValue - oldValue) / 100;
    for (var i = 0; i &lt; 100; i++) {
      oldValue += diff;
      $(element).text(oldValue);
    }
  }
  </pre>
  
  <p></code>
  However, Javascript doesn't seem to refresh the display until AFTER the script is done - thus there's no effect.</p>
  
  <p>How do I make sure the intermediate values are displayed at each step?</p>