Currently, I am using JQuery to create a continuous slideshow of text values. However, after some time, multiple texts start to display simultaneously, indicating a timing issue. Even when hidden, the problem persists. My code includes 3 strings of text.
<h3 class="s1" style="display:none;"> ONE! </h3>
<h3 class="s2" style="display:none;"> TWO! </h3>
<h3 class="s3" style="display:none;"> THREE! </h3>
The function in my code looks like this:
setInterval(function(){
$(".s1").fadeIn(1000);
$(".s1").fadeOut(1000,function(){
$(".s2").fadeIn(1000);
$(".s2").fadeOut(1000,function(){
$(".s3").fadeIn(1000);
$(".s3").fadeOut(1000); });
}); },6000);
Initially, the script works smoothly but after a while (around 30 seconds or more), the strings start overlapping. Ideally, the output should look like:
0:01 --> ONE!
0:02 -->
0:03 --> TWO!
0:04 -->
0:05 --> THREE!
0:06 -->
0:07 --> ONE!
However, what actually happens is something like:
0:01 --> ONE!
0:02 -->
0:03 --> TWO!
0:04 -->
0:05 --> THREE!
ONE!
0:06 -->
0:07 --> TWO!
ONE!
... --> ONE!
... --> TWO!
... --> THREE!
How can I modify the code so that each string appears only after the previous one has disappeared completely?