Skip to content

Instantly share code, notes, and snippets.

@freshyill
Last active February 27, 2020 18:19
Show Gist options
  • Save freshyill/b31765c18cf44589e7def6a2c7013508 to your computer and use it in GitHub Desktop.
Save freshyill/b31765c18cf44589e7def6a2c7013508 to your computer and use it in GitHub Desktop.
Extremely simple active nav highlighting with JS
let links = document.querySelectorAll(".nav a");
for (var i = 0; i < links.length; i++) {
if (links[i].pathname == window.location.pathname) {
links[i].classList.add("current");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment