Skip to content

Instantly share code, notes, and snippets.

@karenpayneoregon
Last active September 25, 2025 17:40
Show Gist options
  • Select an option

  • Save karenpayneoregon/c5c15e5ad6f4079879079fd172acc75f to your computer and use it in GitHub Desktop.

Select an option

Save karenpayneoregon/c5c15e5ad6f4079879079fd172acc75f to your computer and use it in GitHub Desktop.
Add page indicator for ASP.NET Core projects

Add the code to an ASP.NET Core project to indicate the current page.

document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('.nav-link').forEach(link => {
link.classList.remove('border-bottom');
link.classList.remove('border-top');
if (link.getAttribute('href').toLowerCase() === location.pathname.toLowerCase()) {
link.classList.add('border-dark');
link.classList.add('border-bottom');
link.classList.add('border-top');
} else {
link.classList.add('text-dark');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment