Skip to content
Advertisement

How to make active button color in jquery?

var $ = jQuery
$(document).ready(function(){
    $('[data-target]').on('click', function(){
        var target = $(this).attr('data-target')
        $('.all-section').hide()
        $('#' + target).show()
    })
})

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.

.active-btn {
background-color: #232369;
color: white;

}

$('a[val="Sample"]').addClass('active-btn');

<a href="#" class="btn btn-primary" val="Sample">Sample</a>

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

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