-2

我正在使用一个名为 Background stretcher 的 jQuery 插件,这是初始化它的代码。当我在回调函数中按下链接时,网站开始挂起,所以有没有更好的方法可以编写......

$(document).ready(function(){

    //  Initialize Backgound Stretcher     
    $('BODY').bgStretcher({
        images: ['images/exterior.jpg', 'images/exterior2.jpg','images/kitchen.jpg','images/bathroom.jpg','images/bedroom.jpg'],
        imageWidth: 1800, 
        imageHeight: 1400, 
        slideDirection: 'N',
        slideShowSpeed: 1000,
        nextSlideDelay: 6000,
        transitionEffect: 'fade',
        sequenceMode: 'normal',
        buttonPrev: '.prev',
        buttonNext: '.next',
        pagination: '.pagination',
        anchoring: 'left center',
        anchoringImg: 'left center',
        callbackfunction: function() {

                    $('a#design').click(function(){
                        $().bgStretcher._clearTimeout();
                        $().bgStretcher.slideShow('normal', 0);
                        $().bgStretcher.play();
                    });
                    $('a#interior').click(function(){
                        $().bgStretcher._clearTimeout();
                        $().bgStretcher.slideShow('normal', 1);
                        $().bgStretcher.play();
                    });
                    $('a#lifestyle').click(function(){
                        $().bgStretcher.pause();
                        $().bgStretcher.slideShow('normal', 2);
                        $().bgStretcher.play();
                    });
                    $('a#location').click(function(){
                        $().bgStretcher.pause();
                        $().bgStretcher.slideShow('normal', 3);
                        $().bgStretcher.play();
                    });
                    $('a#contact').click(function(){
                        $().bgStretcher.pause();
                        $().bgStretcher.slideShow('normal', 4);
                        $().bgStretcher.play();
                    });

        }
    });
});

写这个更有效/更清洁的方法是什么?

4

1 回答 1

0

而不是$()你应该写$('body')所以尝试这样使用它:

.
.
.
//  Initialize Backgound Stretcher     
    $('body').bgStretcher({
.
.
.
.
                    $('a#design').click(function(){
                        $('body').bgStretcher._clearTimeout();
                        $('body').bgStretcher.slideShow('normal', 0);
                        $('body').bgStretcher.play();
                    });
.
.
.
于 2013-10-21T07:22:43.240 回答