Topic: Tab navigation with buttons
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 5 years 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 5 years 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!
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Pro
- Premium support: No
- Technology: MDB jQuery
- MDB Version: 4.9.0
- Device: All
- Browser: All
- OS: All
- Provided sample code: No
- Provided link: Yes