In the web app, I have a tabbed page that allows users to filter restaurants based on budget and cuisine. The search results are categorized into meals, snacks, and drinks tabs.
Each tab is designed as a button with a corresponding window displayed below it.
Here is the code for the tabs:
<ul class="nav tabs" id="tabs">
<li id="selectMeals">
<button href="#filterTab" data-toggle="tab" class="btn meals-tab">MEALS</button>
</li>
<li id="selectSnacks">
<button href="#filterTab" data-toggle="tab" class="btn snacks-tab">SNACKS</button>
</li>
<li id="selectDrinks">
<button href="#filterTab" data-toggle="tab" class="btn drinks-tab">DRINKS</button>
</li>
</ul>
The buttons link to a specific div that displays content associated with each tab:
<div class="tab-content">
<div id="filterTab" class="tab-pane meals-tab-box">
<div class="results"></div>
</div>
</div>
Currently, when clicking on any tab, the background color of the content does not match the tab's color. This is because the
<div id="filterTab" class="tab-pane meals-tab-box">
only has the "meals-tab-box" class applied by default, rather than changing based on the selected tab. Is there a way to use Javascript to dynamically change the class of this div when switching tabs?