Created
February 17, 2015 13:41
-
-
Save OatmealBath/5929c167091b3e00909e to your computer and use it in GitHub Desktop.
Active Links jQuery
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
// Add active class to links to current page | |
jQuery(document).ready(function(){ | |
console.log(document.location); | |
jQuery('a[href="'+document.location.href+'"]').addClass('active'); | |
jQuery('a[href="'+document.location.origin+document.location.pathname+'"]').addClass('active'); | |
jQuery('a[href="'+document.location.pathname+'"]').addClass('active'); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment