Skip to content
Advertisement

How switch Bootstrap 5 tabs (button version) with javascipt

I want to programmable switch tabs (using bootstrap 5). Bootsrap docs say:

As a best practice, we recommend using elements for the tabs, as these are controls that trigger a dynamic change, rather than links that navigate to a new page or location.

So I want use buttons instead links. Code:

JavaScript
JavaScript

Problem is wrong selector. But I have no idea why.

Advertisement

Answer

You’ll want to use getOrCreateInstance instead because the Tabs aren’t being first initialized via JS.

JavaScript

https://codeply.com/p/kjHOlPJFnN

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement