I created a function that changes the background image of <body>
every 5 seconds, but I wanted to insert a transition effect between the images: Fade Out to black at the start of the transition and then Fade In to the next image. Is there any way to do this (either with JQuery or not)? Here is the function code:
function BackgroundChange() {
var image = ["one","two","three","four","five","six","seven","eight"];
var index = 0;
window.setInterval(function BackgroundChangeSetImage() {
index = index + 1;
if ((index >= 0) && (index <= 7)) {
document.getElementsByTagName("body")[0].setAttribute("style","background-image: url('images/image_" + image[index] + ".jpg');");
} else {
index = -1;
return BackgroundChangeSetImage();
}
}, 5000);
}