调用jquery jCarousel的next和prev函数? [英] Call next and prev function of jquery jCarousel?

查看:114
本文介绍了调用jquery jCarousel的next和prev函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jCarousel创建滚动内容(请按照此 http://sorgalla.com/projects/jcarousel/ )。但我不想使用默认的下一个和上一个按钮,所以我想创建2个按钮来处理点击事件。 EX:我有2个超链接,像这样:

I use jCarousel for creating a scroll content (follow this http://sorgalla.com/projects/jcarousel/). However I dont want to use the default next and previous button so I want to create 2 buttons for handling the click event. EX: I have 2 hyperlinks like these:

<script>
jQuery(document).ready(function() {
    // Initialise the first and second carousel by class selector.
    // Note that they use both the same configuration options (none in this case).
    jQuery('#scrollArea').jcarousel({
        scroll: 10
        });
</script>
        <a>NEXT</a>
        <a>PREV</a>
    <div id="scrollArea">
<!-- CONTENT HERE -->
</div>

如何将下一个和上一个函数绑定到上述链接?

How can I bind the next and prev functions to above links?

推荐答案

查看此示例:

http://sorgalla.com/projects/jcarousel/examples/static_controls.html

基本上,您可以在轮播初始化中将函数附加到轮播。这是相关的代码段。

Basically, you can attach functions to the carousel in the initialization for the carousel. Here is the relevant snippet.

function mycarousel_initCallback(carousel) {
    jQuery('#mycarousel-next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('#mycarousel-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};

这篇关于调用jquery jCarousel的next和prev函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆