I am trying to change the background image of div using the following script:
$.fn.preload = function() {
this.each(function(){
$('<img/>')[0].src = this;
});
}
$(document).ready(function(){
var images = [];
for( var i=0; i<8; i++){
images[i] = 'imgs/'+i+'.png';
}
$(images).preload();
var i = 0;
setInterval(function(){
$('.header').css({'background-image':'url(imgs/'+i%8+'.png)'});
i++;
}, 700);
});
but the images flicker on both chrome and firefox on change, how tp solve this?