Usage

Calling methods on the jCarousel instance

If you have created a carousel like:

$(function() {
    $('.jcarousel').jcarousel();
});

You can later call methods on the jCarousel instance like:

$('.jcarousel').jcarousel('scroll', '+=2');

The first argument is the method name. The following arguments are the arguments for the called method.

See API for available methods.

Defining the number of visible items

You simply define the number of visible items by defining the width (or height for a vertical carousel) of the root element (if you use the default from this document, you do that with the class .jcarousel in your stylesheet).

This offers a lot of flexibility, because you can define the width in pixel for a fixed carousel or in percent for a flexible carousel.

Fixed carousel, always 3 visible items:

.jcarousel {
    position: relative;
    overflow: hidden;
    width: 300px;
}

.jcarousel li {
    float: left;
    width: 100px;
}

Flexible carousel, the number of visible items depend on the width of the root’s parent element:

.jcarousel {
    position: relative;
    overflow: hidden;
    width: 100%;
}

.jcarousel li {
    float: left;
    width: 100px;
}

Vertical carousels

jCarousel tries to auto-detect the orientation by simply checking if the list elements’s height is greater than the list element’s width.

If that doesn’t work, you can explicitly pass the vertical option:

$('.jcarousel').jcarousel({
    vertical: true
});

RTL (Right-To-Left) carousels

jCarousel tries to auto-detect if the carousel should run in RTL mode by looking for a dir attribute with the value rtl on the root or any of its parent elements.

<div class="jcarousel" dir="rtl">
    <ul>
        <!-- The content goes in here -->
    </ul>
</div>

Alternatively, you can explicitly pass the rtl option:

$('.jcarousel').jcarousel({
    rtl: true
});

Note

When running a carousel in RTL mode, you should ensure to float the items to the right:

.jcarousel[dir=rtl] li {
    float: right;
}