How to Get total and Current Slide Number of Carousel

前端 未结 7 1382
野的像风
野的像风 2020-12-07 20:58

Can you please let me know how I can get the total and current number of the carousel slides in bootstrap like the image below?

7条回答
  •  醉梦人生
    2020-12-07 21:29

    You can use jquery index() function to get the current index of active element inside list of item. So the code is look like this:

    var currentItem = $("#carousel-1 .item.active" );
    var currentIndex = $('#carousel-1 .item').index(currentItem) + 1;
    

提交回复
热议问题