Twitter Bootstrap Carousel - access current index

后端 未结 9 1259
面向向阳花
面向向阳花 2020-12-02 14:11

How do I get the current index from the carousel?

In this case I am using an unordered list. I know I could search through the list items to find the one with the \'

9条回答
  •  执念已碎
    2020-12-02 14:53

    This worked for me (Bootstrap 3)

    $("#myCarousel").on('slide.bs.carousel', function(evt) {
      console.debug("slide transition started")
      console.debug('current slide = ', $(this).find('.active').index())
      console.debug('next slide = ', $(evt.relatedTarget).index())
    })
    

提交回复
热议问题