滚动到jcarousel的第一项

Chr*_*ris 5 javascript jquery jcarousel

我在选项卡式界面的页面上有多个jcarousel实例.我需要能够在单击相关选项卡时滚动到每个轮播的第一项,并且我不确定如何执行此操作.我已经看过静态控件示例(http://sorgalla.com/projects/jcarousel/examples/static_controls.html),但无法理解如何让它适用于多个轮播.

任何帮助将大大赞赏.我的工作进展如下:http://www.brainsdesign.com/client/Lab/14512/style.html

非常感谢,

克里斯

Lar*_*ipp 4

你可以使用类似的东西:

jQuery('#myCarousel')
     .jcarousel('scroll',position); 
Run Code Online (Sandbox Code Playgroud)

其中position是你的jcarousel的开始或者你想要到达的索引。

这是来自 jquery.jcarousel.js 源文件:

 /**
     * Scrolls the carousel to a certain position.
     *
     * @method scroll
     * @return undefined
     * @param i {Number} The index of the element to scoll to.
     * @param a {Boolean} Flag indicating whether to perform animation.
     */
    scroll: function(i, a) {
        if (this.locked || this.animating) {
            return;
        }

        this.pauseAuto();
        this.animate(this.pos(i), a);
    },
Run Code Online (Sandbox Code Playgroud)