Automatically changing background images

Automatically changing background images


Hi guys,

Working on the random quote generator and I’m trying to have my background images change. I have been googling and cannot find a good solution to this. I currently have a script that “seemingly” is transitioning through images, but is not displaying the images. Could anyone take a look/help me out? Would be greatly appreciated!

This is the JS:

 var images = ["bjj2.jpg", "bjj3.jpg"];
$(function () {
    var i = 0;
    $("#dvImage").css("background-image", "url(images/" + images[i] + ")");
    setInterval(function () {
        if (i == images.length) {
            i = 0;
        $("#dvImage").fadeOut("slow", function () {
            $(this).css("background-image", "url(images/" + images[i] + ")");
    }, 1000);


Hey! You forgot to put you images in the folder “images”. Although in the code the path is images/… Do that and it’ll work.


You’re the best! Thanks so much!

Only issue is that now I don’t know how to make the whole page the image. It (obviously) is limiting it to the div. Any solution for that?