Twitter Bootstrap Carousel - access current index

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

    I'm doing it like that, that works sort of very well ;)

    var slider = $("#slider-wrapper")
        .carousel({
            interval: 4000
        })
        .bind('slid', function() {
            var index = $(this).find(".active").index();
            $(this).find("a").removeClass('pager-active').eq(index).addClass('pager-active');
        });
    
    $("#slider-wrapper a").click(function(e){
        var index = $(this).index();
        slider.carousel(index);
        e.preventDefault();
    });
    

提交回复
热议问题