Last active
March 27, 2017 04:59
-
-
Save uwang/b9db3972a6a4c037abe9fc564f610ef4 to your computer and use it in GitHub Desktop.
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
$(document).ready(function () { | |
$("ul.nav").find("li").each(function () { | |
var isCurrent = false; | |
$(this).find("a").each(function() { | |
// console.log($(this).attr("href") + "," + location.pathname); | |
if ($(this).attr("href") === location.pathname) { | |
isCurrent = true; | |
} | |
}); | |
if (isCurrent) { | |
$(this).addClass("active"); | |
} else { | |
$(this).removeClass("active"); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment