This code changes the background every 20 seconds to
How do I insert the fadein and fadeout effect ?
My jQuery code
var bg = $('#bg');
var backgrounds = new Array(
'url(1.jpg)',
'url(2.jpg)',
'url(3.jpg)',
'url(4.jpg)');
var current = 0;
function nextBackground() {
bg.css(
'background',
backgrounds[current = ++current % backgrounds.length]);
setTimeout(nextBackground, 20000);
}
setTimeout(nextBackground, 20000);
bg.css('background', backgrounds[0]);