Twitter Bootstrap Carousel - access current index

后端 未结 9 1262
面向向阳花
面向向阳花 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:51

    Instead of adding and subtracting from the current slide, try this on the 'slide' event:

    $('.carousel').on('slide',function(e){
        var slideFrom = $(this).find('.active').index();
        var slideTo = $(e.relatedTarget).index();
        console.log(slideFrom+' => '+slideTo);
    });
    

提交回复
热议问题