Created
December 28, 2014 03:36
-
-
Save haojianzong/c7ab2b71a4f955b1bbdb to your computer and use it in GitHub Desktop.
jQuery Auto Active Menu
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
// this function will active menu using href match | |
// Author: http://www.paulund.co.uk/use-jquery-to-highlight-active-menu-item | |
function auto_active_menu() {¬ | |
var url = window.location.href;¬ | |
// Work for relative and absolute hrefs¬ | |
$('.menu a').filter(function() { | |
return this.href == url;¬ | |
}).addClass('active');¬ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment