在我的测试网站http://www.behringer-mauch.de/Tischler_Hehmann/index.php上我有一个背景图片切换器用于我的包装容器。代码在basic.js中,我将在我的代码中插入fadeIn()jQuery Animate。但我不知道我要把它放在哪里。
这里是我的代码:
var images = ['layout/images/background_image.jpg', 'layout/images/background_image_2.jpg'];
var i = 0;
var timeoutVar;
function changeBackground() {
clearTimeout(timeoutVar); // just to be sure it will run only once at a time
jQuery("#wrapper").css('background-image', function() {
if (i >= images.length) {
i=0;
}
return 'url(' + images[i++] + ')';
});
// call the setTimeout every time to repeat the function
timeoutVar = setTimeout(changeBackground, 3000);
}
$( document ).ready(function() {
$( "#logo" ).click(function() {
window.location.href="index.php";
});
// Call it on the first time and it will repeat
changeBackground();
});