Last active
September 23, 2016 02:56
-
-
Save yagamicoder/ff3c599701f0cee4032530d59a7a027b to your computer and use it in GitHub Desktop.
Highlight the current nav link using 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
$.each($('#navigation ul li a'), function(event){ | |
var mylink = $(this).attr("href"); | |
var url = window.location; | |
//If there is a match, apply a class of current, otherwise, remove the class of current | |
if(url == mylink){ | |
$(this).addClass('current'); | |
}else{ | |
$(this).removeClass('current'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment