I am trying to get a background image of an inherited div (by which I mean that it already has a background image that I can’t control and therefore must rewrite initially) so that it fades between new images indefinitely. Here is what I still have:
var images = [ "/images/home/19041085158.jpg", "/images/home/19041085513.jpg", "/images/home/19041085612.jpg" ]; var counter = 0; setInterval(function() { $(".home_banner").css('backgroundImage', 'url("'+images[counter]+'")'); counter++; if (counter == images.length) { counter = 0; } }, 2000);
The problem is that it is not smooth (I am aiming for something like the innerfade plugin).
EDIT: the question initially said, "and it is not vague (it passes only once through the array)., But Mario corrected my dumb naming error.
EDIT2: Now I am using Reigel's answer (see below), which works fine, but I still can’t find a way to smoothly transition between images.
All help is respectfully appreciated :)
source share