Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
jQuery Auto Active Menu
// 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