I have the code below:
$(document).ready(function() {
var bgimages=new Array()
bgImages[0]="bg.jpg"
bgImages[1]="bg2.jpg"
//sloppy preload images
var pathToImg=new Array()
for (i=0;i<bgImages.length;i++)
{
pathToImg[i]=new Image()
pathToImg[i].src=bgImages[i]
}
var i = 0;
var rotateBg = setInterval(
function(){
$('body').css({backgroundImage:'url(' + bgImages[i] + ')'});
i++;
}, 9000);
});
I need assistance solving 2 issues:
- It will only loop through the images once, what am I missing? I would like it to repeat endlessly.
- How can I cross fade the images in?