Skip to content
Advertisement

how can i dynamically generate different bootstrap tabs with php

I want to generate different bootstrap nav-tabs for each post and the tab list will be vary, basically based on some condition. Some post it may 3 tabs, some post it may 2 but at least 1 tab should be there. Like the following image

enter image description here

The problem i face for each an every post 1st tab class should be .active – which i cant maintain for the rest of the tabs for the same post. Next Tab id for each post and different tab content does not sync properly. it gets duplicated. Also note query is perfect. Just logic problem

Here is the code structure:

JavaScript

Please tell me how can i solve this logic so that for every post all tabs should come properly also first tab with .active class. If the problem is not understandable clearly then please comment. I would change the line. Because i need this help.

Advertisement

Answer

You can try this way

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