Tab navigation with buttons


Topic: Tab navigation with buttons

jouvrard pro asked a year ago

Hello,

I try to navigate through tabs with some buttons, but it doesn't work as expected.

In fact, it seems the ajavscript believe that the active tab is always the first one, but I don't understand why...

Here is my snippet: https://mdbootstrap.com/snippets/jquery/furax/1472061

Thanks!


Mateusz Łubianka staff answered a year ago

Hi,

Your first li element always has 'active' class. Try to add and remove 'active' class in your li elements. Check out an example of code: $('.suivant').on('click', function (e) { e.preventDefault();

$("#myTab li.active").next().children("a").tab("show"); $("#myTab li.active").removeClass('active'); $("#myTab a.active").parent().addClass('active'); });

Best,


jouvrard pro answered a year ago

Hello,

Thanks,But with this code I need to click twice the first time to go to the next tab. :(

https://mdbootstrap.com/snippets/jquery/furax/1472061

EDIT> Sorry it works now. My two buttons had the same class...

Thanks!


Mateusz Łubianka staff commented a year ago

Hi,

I am happy to help.

Best


Please insert min. 20 characters.
Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: No
  • Technology: jQuery
  • MDB Version: 4.9.0
  • Device: All
  • Browser: All
  • OS: All
  • Provided sample code: No
  • Provided link: Yes
Tags