How can i repeat setInterval?
So, i have a function (Duration = 19sec for 1 itteration).
First 4 seconds - label is "text 1", Next 7 seconds - label is "text 2" And next 8 seconds - label is "text 3".
And after 19s it should repeat (I have var of itterations - newCurrentElement) and i also have the hole duration of the function (timeNewCurremtElement).
timeNewCurremtElement and newCurrentElement are known, so you shouldn't worry about it.
I have tried to make a loop (for), but that did't work.
function TextChanger() {
counter = 0;
clearInterval(timer);
function TextChanger_Interval(){
timer = setInterval(function() {
counter++;
if (counter <= 3) {
$('#in-hold-out').html("Inhale");
} else if (counter <= 10) {
$('#in-hold-out').html("Hold");
} else if (counter <= 18) {
$('#in-hold-out').html("Exhale");
} else {
counter = 0;
clearInterval(timer);
}
}, 1000);
}
TextChanger_Interval();
}
TextChanger();
Thank you!