The following code makes an "image fader" in a div
that I have in my document. However, the effect is very 'dry', I would like to have a transition during the exchange of images, like the fade effect of jQuery.
var images = ['image-1.jpg','image-2.jpg','image-3.jpg','image-4.jpg','image-5.jpg','image-6.jpg'],
index = 0,
maxImages = images.length - 1;
var timer = setInterval(function() {
var curImage = images[index];
index = (index == maxImages) ? 0 : ++index;
$('.header').css({'background-image':'url(./img/'+curImage+')'});
}, 1500);
How could I do it?
Follow a fiddle with a small example .