JavaScript
x
9
1
var $ = jQuery
2
$(document).ready(function(){
3
$('[data-target]').on('click', function(){
4
var target = $(this).attr('data-target')
5
$('.all-section').hide()
6
$('#' + target).show()
7
})
8
})
9
This is the code I use in Elementor to make a custom tab section. All thing is working but my active tab does not show any active color. I want to make tab active color like the navigation menu active color.
Advertisement
Answer
you can create class “active-button” and add to your element when get actives.
JavaScript
1
4
1
.active-btn {
2
background-color: #232369;
3
color: white;
4
}
JavaScript
1
4
1
$('a[val="Sample"]').addClass('active-btn');
2
3
<a href="#" class="btn btn-primary" val="Sample">Sample</a>
4
and when other buttons clicked, first deactive all buttons and set active-btn to new one!
you can do this for all your tabs.set class to your all tab sections