Hi all,
I am having a problem that is confusing the hell out of me... I have a small script that highlights the active page. That works. Sort of... The problem is I have three links, out of eight that absolutely refuse to highlight. I have checked everything I can, have found and tried several scripts for this purpose and all of them refuse to highlight the same entries in my nav bar. It looks like I have done everything the same way. This is driving me absolutely batty.
Here is the js.
And for reference here is my nav bar.
There are more entries in the sub UL where it says "Freya's Aett" under Runes but I thought just the one sub would suffice for illustration purposes. But, that is one I am having a problem getting the highlighting on. Along with the second entry, Rune List, and the seventh entry about.
Any insight greatly appreciated. As I said before I have tried several scripts, but NONE of them will highlight the same ones so I am completely at a loss.
Thanks for reading!
Jim
I am having a problem that is confusing the hell out of me... I have a small script that highlights the active page. That works. Sort of... The problem is I have three links, out of eight that absolutely refuse to highlight. I have checked everything I can, have found and tried several scripts for this purpose and all of them refuse to highlight the same entries in my nav bar. It looks like I have done everything the same way. This is driving me absolutely batty.
Here is the js.
JavaScript:
<script>
const menuitems = document.querySelectorAll("a");
for (let i=0; i < menuitems.length; i++) {
menuitems[i].addEventListener("click", (e) => {
for (let i=0; i < menuitems.length; i++) {
menuitems[i].classList.remove("current");
}
e.target.classList.add("current");
e.preventDefault();
});
}
</script>
And for reference here is my nav bar.
HTML:
<ul id="nav">
<li><a href="index.php">Home</a></li>
<li><a href="runelist.php">Rune List</a></li>
<li><a href="alpha.php">Runic Alphabet</a></li>
<li><a href="trans.php">Runic Transliteration</a></li>
<li><a href="aetts.php">The Aetts</a></li>
<li><a href="runes.php">Runes</a></li>
<ul>
<li>Freya's Aett</li>
</ul>
<li><a href="about.php">About</a></li>
<li><a href="contact.php">Contact</a></li>
</ul>
There are more entries in the sub UL where it says "Freya's Aett" under Runes but I thought just the one sub would suffice for illustration purposes. But, that is one I am having a problem getting the highlighting on. Along with the second entry, Rune List, and the seventh entry about.
Any insight greatly appreciated. As I said before I have tried several scripts, but NONE of them will highlight the same ones so I am completely at a loss.
Thanks for reading!
Jim