无法使用bootstrap 4自动更改选项卡

时间:2018-06-14 11:23:50

标签: bootstrap-4

我在HTML页面的Bootstrap中使用nav-tabs。它们正在工作但我希望在10秒后自动移动到下一个选项卡而不单击选项卡。有人能告诉我怎么做吗?我发现很少有博客,但这不适用于Bootstrap 4。

1 个答案:

答案 0 :(得分:0)

https://getbootstrap.com/docs/4.1/components/navs/#javascript-behavior中所述,您可以使用javascript更改标签:

  

您可以通过多种方式激活各个标签:

$('#myTab a[href="#profile"]').tab('show') // Select tab by name
$('#myTab li:first-child a').tab('show') // Select first tab
$('#myTab li:last-child a').tab('show') // Select last tab
$('#myTab li:nth-child(3) a').tab('show') // Select third tab

将其与正确的选择器和javascripts setIntervalhttps://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval)相结合,以实现您想要的行为。