example to Animate background with jQuery 1 currentID = Math.floor(Math.random()*imgs.length) 2 newImage = "url(" + imgs[currentID] + ")"; 3 $("#topdiv").animate({opacity: 'toggle'}, "slow", function () 4 { 5 document.getElementById('topdiv').style.backgroundImage = newImage; 6 $("#topdiv").animate({opacity: 'toggle'}, "slow"); 7 } 8 ); change div background document.getElementById('topdiv').style.backgroundImage = newImage;