Last active
July 9, 2019 15:26
-
-
Save RoseCrime/6b18ddf3579d0d7219b7de03216bd3ce to your computer and use it in GitHub Desktop.
Hightlight active menu link
This file contains hidden or 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
let lastlink = location.pathname.split('/').filter(el => el) | |
lastlink = lastlink[lastlink.length - 1] | |
$('.category_sidebar a').each((index, element) => { | |
//.category_sidebar a is just selector for your menu links | |
let href = $(element).attr('href').split('/').filter(el => el) | |
href = href[href.length - 1] | |
if (lastlink == href) | |
$(element).addClass('current-link') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment