Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get current index of jCarouselLite image/page

I've looked through the other questions about this and not found a suitable answer.

What I need is very simple: The index of the currently shown item.

Here's my little chunk of config

    $('.carousel').jCarouselLite(
    { 
        btnNext: "#right-navigation",
        btnPrev: "#left-navigation",
        visible: 1,
        afterEnd: function(a)
        {
            // Code that requires the index
        }
    });

Note: the a is an object

Thanks!

like image 465
Alex Avatar asked Jan 20 '23 13:01

Alex


1 Answers

The elements representing the items that are visible after the animation ends are passed in as argument.

so you should be able to do something like

afterEnd: function(a){
   var index = $(a[0]).index();
}

to get the index of the first element

like image 164
Andy Avatar answered Jan 25 '23 23:01

Andy