Skip to content

Instantly share code, notes, and snippets.

@uddhabh
Created November 28, 2021 06:11
Show Gist options
  • Save uddhabh/7ad62deaa5d2fe744762cbd2163ac05a to your computer and use it in GitHub Desktop.
Save uddhabh/7ad62deaa5d2fe744762cbd2163ac05a to your computer and use it in GitHub Desktop.
(function ($) {
'use strict';
/*===================================
= Menu Activeion =
===================================*/
var cururl = window.location.pathname;
var curpage = cururl.substr(cururl.lastIndexOf('/') + 1);
var hash = window.location.hash.substr(1);
if ((curpage == '' || curpage == '/' || curpage == 'admin') && hash == '') {
//$("nav .navbar-nav > li:first-child").addClass("active");
} else {
$('.navigation-menu li').each(function () {
$(this).removeClass('active');
});
if (hash != '')
$(".navigation-menu li a[href*='" + hash + "']")
.parents('li')
.addClass('active');
else
$(".navigation-menu li a[href*='" + curpage + "']")
.parents('li')
.addClass('active');
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment