Skip to content

Instantly share code, notes, and snippets.

@alex-eri

alex-eri/menu.js

Created Jun 26, 2020
Embed
What would you like to do?
var loc = window.location.href;
var url_segments = loc.split('/');
url_segments.pop();
vat url_segment = url_segments.pop();
$('.menu li').each(function () {
var link = $(this).find('a').attr('href');
var link_segments = link.split('/');
link_segments.pop()
link_segment = link_segments.pop()
if (link_segment == url_segment)
{
$(this).addClass('current-menu-item');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.