javascript - 滚动到 jcarousel 的第一项

标签 javascript jquery jcarousel

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

任何帮助将非常感激。我正在进行的工作在这里:http://www.brainsdesign.com/client/Lab/14512/style.html

非常感谢,

克里斯

最佳答案

你可以使用类似的东西:

jQuery('#myCarousel')
     .jcarousel('scroll',position); 

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);
    },

关于javascript - 滚动到 jcarousel 的第一项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4589893/

相关文章:

javascript - 'referral links' 是如何被发现的?

java - Spring - @RequestBody 阻止请求?

javascript - 如何减少对每个空选择使用错误消息

javascript - 帮助表单上的appendTo() jquery函数

html - Ocassions WP 主题中的 jCarousel 在除主页以外的所有页面上都是垂直的

javascript - Modernizr toString

javascript - 为什么 CSS transform-origin 和 transform 不能一起过渡?

javascript - 如何使用 jquery 从 Sharepoint 用户配置文件数据库获取用户

jquery-plugins - 带有动态加载图像和链接的 Javascript 或 jQuery 图像轮播

jQuery - 尝试创建 'endless slideshow' 的图像