Skip to content

Instantly share code, notes, and snippets.

@alex-eri
Created June 26, 2020 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alex-eri/207ed38c46c2fd912fc2344a5ea3750b to your computer and use it in GitHub Desktop.
Save alex-eri/207ed38c46c2fd912fc2344a5ea3750b to your computer and use it in GitHub Desktop.
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