carouFredSel:为next/prev按钮创建一个函数

carouFredSel: Create a function for next / prev buttons?

本文关键字:函数 一个 创建 按钮 next prev carouFredSel      更新时间:2023-09-26

我正在使用carouFredSel在同一页面上创建多个转盘。如果你看看这个JSFiddle,你会发现有两个旋转木马,但只有一个可以用next/prev按钮滚动。

在不添加类或ID的情况下,我试图告诉按钮只滚动相应的转盘。我相信这是通过一个函数来实现的,但我不完全确定如何实现。类似这样的东西:

prev: {
    button: function() {
        $(this).next('.prev');
        }
},

看看这个,它就在文档中:

prev: {
    button: function() {
        return $(this).parent().siblings(".prev");
        }
    },
next: {
    button: function() {
        return $(this).parent().siblings(".next");
        }
    }

工作JSFiddle演示

哦,注意,我取出了key,因为那样你就必须同步旋转木马。。。你可以有一个或另一个,而不是两者都有。(除非您有条件地分配了密钥,但您的小代码会丢失)

--
http://caroufredsel.frebsite.nl/code-examples/configuration.phpsearch:"动态获取按钮和容器的HTML元素"

我认为最好设置一个ID。

$("#list1").carouFredSel({
    direction: "up",
    auto : false,
    items: 3,
    prev : "#prev1",
    next : "#next1"
});   
$("#list2").carouFredSel({
    direction: "up",
    auto : false,
    items: 3,
    prev : "#prev2",
    next : "#next2"
}); 

查看工作演示。

可能这一个对你很有用。在我的页面上,它的工作效果很好。

prev: {
       button  : ".prev"
},
next: {
       button  : ".next"
},