I have the following code that I would like to make fadeIn
and fadeOut
after 3 seconds. I thought I would use setInterval
to loop and then use setTimeout
to give the time each div
was visible. Is there any way to do what I want? I have something wrong with my code?
setInterval(function(){
setTimeout(function(){
$(".emer3").fadeOut("fast");
$(".emer1").fadeIn("fast");
}, 3000);
setTimeout(function(){
$(".emer1").fadeOut("fast");
$(".emer2").fadeIn("fast");
}, 3000);
setTimeout(function(){
$(".emer2").fadeOut("fast");
$(".emer3").fadeIn("fast");
}, 3000);
}, 9000);
<div class="col-lg-12 col-sm-12 col-xs-12 col-md-12" style="margin-top:100px;">
<div class="col-lg-4 col-sm-4 col-xs-4 col-md-4 emer1">
252 252 252
</div>
<div class="col-lg-4 col-sm-4 col-xs-4 col-md-4 emer2" style="display:none">
252 252 252
</div>
<div class="col-lg-4 col-sm-4 col-xs-4 col-md-4 emer3" style="display:none">
252 252 252
</div>
</div>
Example in this JSFIDDLE