如何告诉Bootstrap Carousel转到特定索引

How to tell Bootstrap Carousel to go to a specific index?

本文关键字:索引 何告诉 Bootstrap Carousel      更新时间:2023-09-26

我在一个项目中使用Bootstrap和Bootstrap Carousel。

我想知道是否有任何方法可以让旋转木马导航到特定的幻灯片
例如:

$('myCarousel').to(2);

有人知道怎么做吗?

来自文档:

转盘(数字)将转盘循环到特定帧(基于0,类似于阵列)。

所以我认为应该是:

 $('myCarousel').carousel(2);

使用jQuery选择转盘的元素,并使用.carousel()方法:

$("#myCarousel").carousel(2);

这将带您进入第三张幻灯片。