I have this set of code that fades in and out. What I need is to repeat it over and over, endlessly as long as the page is open.
$(document).ready(function() {
$('.one').fadeTo(500, 1);
$('.one').fadeOut(500, 0, function(){
$('.two').fadeTo(500, 1);
$('.two').fadeOut(500, 0, function(){
$('.three').fadeTo(500, 1);
$('.three').fadeOut(500, 0, function(){
$('.four').fadeTo(500, 1);
$('.four').fadeOut(500, 0, function(){
$('.five').fadeTo(500, 1);
$('.five').fadeOut(500, 0, function(){
$('.six').fadeTo(500, 1);
$('.six').fadeOut(500,0);
});
});
});
});
});
});
$(document).ready(main);
I was thinkging of setInterval, which works, but the whole loop is 60 seconds long and setInterval doesn't start at 0 but at the time that is set.
In this case I would have to set the interval at 60000 and then wait one whole minute before the loop starts.
Is there a simpler way to start the function again? Or is there a way to start the setInterval at 0?