I\'ve created a loop of "changing words" with jQuery by using the code in this answer: jQuery: Find word and change every few seconds
How do I stop it after
You should consider using a recursive setTimeout() instead of setInterval() to avoid a race condition.
var fadecount = 1;
(function interval(){
$('#dennaText').fadeOut(function(){
$(this).html(words[i=(i+1)%words.length]).fadeIn('fast',function(){
if (fadecount < 30){
fadecount += 1;
setTimeout(interval, 2000);
}
});
});
}());