Last active
August 29, 2015 14:03
-
-
Save Linell/9db398b8c68241869df5 to your computer and use it in GitHub Desktop.
Loops through each a tag in the `#navbar` and compares it to the url. If it's a match BOOM add active to it.
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() { | |
p = location.pathname.replace('/', '').split('/')[0]; | |
$("#navbar a").each(function() { | |
if ( $(this).attr('href').replace('/', '') == p ) { | |
$(this).parent().addClass('active'); | |
return; | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment