title: Stop javascript counter once it reaches number specified in div
body: <p>I'm using code from a <a href="http://jsfiddle.net/QgrFq/" rel="nofollow">JSFiddle</a> to implement a count up feature on my site. I like it because it allows me to target a number displayed in a specific div, and I don't need to specify that number in the javascript, which means I can use it on any page for any number I choose.</p>
  
  <p>See the code here:</p>
  
  <pre><code>// basic class implementation
  function myCounter() {
      // privileged property for iteration
      this.i = 0;
  
      // privileged init method
      this.init();
  }
  
  // defining init method
  myCounter.prototype.init = function () {
      // reassign this
      var _this = this;
  
      setInterval(function () {
          // call this.countUp() using our new created variable.
          // this has to be done as this would normally call something 
          // inside this function, so we have to pass it as own
          // variable over
          _this.countUp();
      }, 500);
  
      clearInterval(function () {
          this.i == 
      };
  };
  
  // defining the counter method
  myCounter.prototype.countUp = function () {
      this.i++;
      document.getElementById('counter').innerHTML = this.i;
  };
  
  // create a new instance of our counter class
  var counter = new myCounter();
  </code></pre>
  
  <p>The only problem is that it doesn't stop counting. I'd love to add some code for that myself, except I'm not familiar enough with javascript and have no idea where to start.</p>
  
  <p>Is there a way to tell javascript to stop counting at the number specified in the targeted div?</p>
  
  <p>Thanks so much!</p>