I have a div container that contains an unordered list tab menu. By clicking on each tab, the menu content changes correspondingly. The functionality is working well, but I want to alter the background image of the container div based on which li is clicked.
Below is my HTML markup:
<div class="menu-container menu-container-starters">
<ul class="tabs">
<li class="active" data-trigger-class="menu-container-starters">Starters Content</li>
<li data-trigger-class="menu-container-mains">Mains Content</li>
<li data-trigger-class="menu-container-drinks">Drinks Content</li>
<li data-trigger-class="menu-container-desserts">Desserts Content</li>
</ul>
</div>
I have assigned background images to the following classes:
.menu-container-starters
.menu-container-mains
.menu-container-drinks
.menu-container-desserts
This is my JavaScript code:
$('.tabs li').click(function(){
$('.menu-container').removeClass('.menu-container-starters .menu-container-mains .menu-container-drinks .menu-container-desserts');
$('.menu-container').addClass($(this).attr('data-trigger-class'));
});