Created
October 5, 2010 04:10
-
-
Save levifig/610978 to your computer and use it in GitHub Desktop.
Goes through the links in my <nav> and compares their own 'href' with the current URL.
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
// Goes through the links in my navigation and compares their own 'href' with the current URL | |
// Really handy and I'm sure I'll reuse hence posting it here. ;) | |
// Thank you to Paul Irish (#jquery @ freenode.net) for the indexOf recommendation! ;) | |
$('nav ul li a').each(function() { | |
if (location.pathname.indexOf($(this).attr('href')) > -1 ) { | |
$(this).addClass('active'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment