Getting Index of Current Item in JCarousel

前端 未结 11 1721
夕颜
夕颜 2021-02-05 20:25

I am attempting to get the index of the current item in a JCarousel so that I can display the current position within the Carousel to the user. For example, \'13/20\'.

H

11条回答
  •  春和景丽
    2021-02-05 20:54

    If you have pagination (bullets)

    you can simply use:

    var index = $('.active').html();
    

    jcarousel is adding class 'active' to active bullet, if you have numbers on the bullets you just retrieve them by .html() method

    Also you can turn them to integers by parseInt:

    var index = parseInt($('.active').html());
    

提交回复
热议问题