1
我想創建使用JQuery背景圖片更換,我迄今成功了,但是我對不確定如何或在哪裏我的代碼添加.fadeIn()作用:JQuery的添加淡入淡出效果
$(function() {
var body = $('.div-slideshow');
var backgrounds = [
'url(img/homeImg.jpg)',
'url(img/homeImg2.jpg)',
'url(img/homeImg3.jpg)'
];
var current = 0;
function nextBackground() {
body.css(
'background',
backgrounds[current = ++current % backgrounds.length]);
setTimeout(nextBackground, 5000);
}
setTimeout(nextBackground, 5000);
body.css('background', backgrounds[0]);
});