0
我写这个剧本旋转背景图像,每3秒,但它并没有在所有的工作和我难倒,为什么不。jQuery的背景图像旋转脚本不起作用
$(document).ready(function() {
var inc = 0;
var bgImages = new Array();
bgImages.push("Images/backgroundDog-small.jpg");
bgImages.push("Images/backgroundDog1-small.jpg");
bgImages.push("Images/backgroundDog2-small.jpg");
bgImages.push("Images/backgroundDog3-small.jpg");
setInterval(change, 3000);
function change() {
//if we're not at the end of the array
if (inc < (bgImages.length)) {
var image = bgImages[inc];
$('body').css('backgroundImage', image);
console.log(image);
inc++;
//reset the counter inc and go through the array again
} else {
inc = 0;
}
}
});
会发生什么?图像路径是否正确? – SLaks 2010-03-25 02:13:49
的背景是白色的。是的,图像路径是正确的。 – Catfish 2010-03-25 02:16:32