Created
February 20, 2014 16:54
-
-
Save revaboogy/9118310 to your computer and use it in GitHub Desktop.
Adding Class to current menu item or link
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() { | |
// Get current url | |
// Select an a element that has the matching href and apply a class of 'active'. Also prepend a - to the content of the link | |
var url = window.location.href; | |
$('#main-menu a[href="'+url+'"]').addClass('current_page_item'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment