滑块不能在同一页面上工作两次

slider does not work twice on the same page

本文关键字:工作 两次 不能 一页      更新时间:2023-09-26

我试图在页面上使用相同的幻灯片两次,但不工作。只工作第一。当我复制html时,图像不会出现在第二个滑块中。

代码
$(function(){
        $('#slides2').slides2({
            preload: true,
            preloadImage: 'img/loading.gif',
            play: 0,
            pause: 2500,
            hoverPause: true,
            animationStart: function(current){
                $('.caption').animate({
                    bottom:-35
                },100);
                if (window.console && console.log) {
                    // example return of current slide number
                    console.log('animationStart on slide: ', current);
                };
            },
            animationComplete: function(current){
                $('.caption').animate({
                    bottom:0
                },200);
                if (window.console && console.log) {
                    // example return of current slide number
                    console.log('animationComplete on slide: ', current);
                };
            },
            slidesLoaded: function() {
                $('.caption').animate({
                    bottom:0
                },200);
            }
        });
    });

函数slides2不存在于您发布的滑块插件的代码中。再次使用slides。当然是在另一个具有不同ID的元素上。这就是我在回答你的问题时想要找出的答案。

第一个可以使用:

 $('#slides1').slides({

第二次使用:

$('#slides2').slides({