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