-
-
Save yuriitaran/27b4fcd0a49621ea632fed2cb776b711 to your computer and use it in GitHub Desktop.
jQuery Active Menu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Active menu | |
$("li a").each(function() { | |
if (this.href == window.location.href) { | |
$(this).addClass("active"); | |
} | |
}); | |
// second way | |
var url = window.location.pathname, | |
urlRegExp = new RegExp(url.replace(/\/$/,"") + "$"); | |
$(".box-mnu a").each(function(){ | |
if(urlRegExp.test(this.href.replace(/\/$/,""))){ | |
$(this).addClass("active"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment