I'm trying to get this script to loop, yet I can't.
$(document).ready(function inout() {
$('#review1').fadeIn(1500).delay(3500).fadeOut(1500);
$('#review2').delay(3500).fadeIn(1500).delay(3500)
});
I'm trying to get this script to loop, yet I can't.
$(document).ready(function inout() {
$('#review1').fadeIn(1500).delay(3500).fadeOut(1500);
$('#review2').delay(3500).fadeIn(1500).delay(3500)
});
If you want review1 to fadeIn, then fadeOut, then review2 to fadeIn, then fadeOut with delays between, you can do it like this;
$(document).ready(function inout() {
function cycle() {
$('#review1').fadeIn(1500).delay(3500).fadeOut(1500, function() {
$('#review2').delay(3500).fadeIn(1500).delay(3500).fadeOut(1500, function() {
setTimeout(cycle, 1500);
});
});
}
cycle();
});
This uses the jQuery animation completion function in order to link separate animations so one starts after the other completes. These are asynchonous animations so you can't just use normal sequential programming.