23 February 2023

How to Keep active navbar according to url in jQuery?

Stay active navbar according to url in jQuery


<script>

    /** add active class and stay opened when selected */

var url = window.location;


// for sidebar menu entirely but not cover treeview

$('ul.nav-sidebar a').filter(function() {

    return this.href == url;

}).addClass('active');


// for treeview

$('ul.nav-treeview a').filter(function() {

    return this.href == url;

}).parentsUntil(".nav-sidebar > .nav-treeview").addClass('menu-open').prev('a').addClass('active');

</script> 

No comments:

Post a Comment

How to add re-captcha v3 on all Elementor forms using coding?

 Add re-captcha v3 on all Elementor forms using coding add_action('wp_footer',function(){     ?> <script src="https://www...