Getting Index of Current Item in JCarousel

前端 未结 11 1825
夕颜
夕颜 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 21:01

    You can hook into the 'jcarousel:animate' event, and grab the current slide as a jQuery Object.

    $('#mycarousel').on('jcarousel:animate', function(event, carousel) {
      console.log(carousel._target); // this outputs your current slide as jQuery object.
    });
    

提交回复
热议问题