Last active
October 11, 2022 19:02
-
-
Save fagci/014739a21f59c02f899324b95c55f8c2 to your computer and use it in GitHub Desktop.
Untitled
This file contains 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
.active { | |
font-weight: bold; | |
color: red; | |
} |
This file contains 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
<div id="nav1"> | |
<a href="https://dabblet.com/gist/111">Not Current</a> | |
<a href="https://dabblet.com/gist/014739a21f59c02f899324b95c55f8c2">Current</a> | |
</div> | |
<div id="nav2"> | |
<a href="https://dabblet.com/gist/222">Not Current</a> | |
<a href="https://dabblet.com/gist/014739a21f59c02f899324b95c55f8c2">Current</a> | |
</div> |
This file contains 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
const links = document.querySelectorAll("#nav2 a"); | |
const linksCount = links.length; | |
console.log(links); | |
for (let i = 0; i < linksCount; i++) { | |
console.log(123) | |
if (window.location.href.startsWith(links[i].href)) { | |
links[i].classList.add("active"); | |
} | |
} |
This file contains 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
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"javascript"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment