AdminLte active current menu using JAVASCRIPT

AdminLte is the most popular and open source admin theme. many developers used AdminLte for developing admin panel. Many Developers use PHP if condition for active the current sidebar menu. It’s hard to manage with if condition when we have many sidebar menus.

I think we should use JAVASCRIPT for active the current menu for the sidebar. it’s too easy and simple js snippets.

$(document).ready(function(){

    var url = window.location;
    // Will only work if string in href matches with location
    $('ul.nav a[href="'+ url +'"]').parent().addClass('active');

    // Will also work for relative and absolute hrefs
    $('ul.nav a').filter(function() {
        return this.href == url;
    }).parent().addClass('active');
});

Just add above code into your javascript file. then checked the “active” class is add onto your current menu.