Active Menu Script

var path = window.location.href;
$("a").each(function() {
    var href = $(this).attr('href');
    if (path == href) {
    $(this).addClass('active');
  }
});


// Option Two if there are special characters being used for foreign pages 


var url = window.location.pathname;
urlRegExp = new RegExp(url.replace(/\/$/, '') + "$");
$("a").each(function() {
    if (urlRegExp.test(this.href.replace(/\/$/, ''))) {
        $(this).addClass('active');
    }
});

Comments

Popular posts from this blog

Pagination of multiple recent post blog

Service Filter

When You Want to open popup(first time load)