Wednesday, 14 August 2013

fade in and out loop with three divs in javascript

fade in and out loop with three divs in javascript

I've used this http://jsfiddle.net/3KydB/ and tried to modify it for 3 divs:
window.switchIn = function () {
$('.chart_1').fadeToggle(function() {
$('.chart_2').fadeToggle(function() {
$('.chart_3').fadeToggle(function() {
setTimeout(function() {window.switchOut();}, 6000);
});
});
});
}
window.switchOut = function () {
$('.chart_3').fadeToggle(function() {
$('.chart_2').fadeToggle(function() {
$('.chart_1').fadeToggle(function() {
setTimeout(function() {window.switchIn();}, 6000);
});
});
});
}
setTimeout(function() {window.switchIn();}, 6000)
The first one fades in and out fine, then the second one fades in with the
third one below it, then back to the first one etc.

No comments:

Post a Comment