This loops forever, how do I stop it at the marked location?
$.fn.writeText = function(content) { var contentArray = content.split(""), current = 0, elem = this; setInterval(function() { if(current < contentArray.length) { elem.text(elem.text() + contentArray[current++]); } else{ //stop here. } }, 100); }; $("#ID").writeText("Texty text text"); Thanks. I think it's supposed to be clearTimeout(), but I'm not sure how.