Add the code to an ASP.NET Core project to indicate the current page.
Last active
September 25, 2025 17:40
-
-
Save karenpayneoregon/c5c15e5ad6f4079879079fd172acc75f to your computer and use it in GitHub Desktop.
Add page indicator for ASP.NET Core projects
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
| 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