Home > OS >  How to make active button color in jquery?
How to make active button color in jquery?

Time:07-30

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.

CodePudding user response:

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="#"  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

  • Related