The code below works fine, until I tried to add a pause into it. Basically, it will loop through and seem normal, but after a few times it sort of catches up to itself and causes a lot of strange reults. I was curious if there is a better way to achieve what I am going for.
var popups = $('.animate');
var i = 0;
var pT = 2000;
function animatePopup() {
if (i >= popups.length){
i = 0;
}
popups.eq(i).addClass("show")
.delay(2000)
.queue(function() {
$(this).removeClass("show");
$(this).dequeue();
if (i == popups.length) {
setInterval(animatePopup, pT);
} else {
animatePopup();
}
});
i++;
}
animatePopup();
setIntervalruns everypTms.. you probably meantsetTimeout