1

在我的测试站点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();


});
4

0 回答 0