0

I have a menu bar with 6 buttons inside <a> tags like this:

<a href = "#"><button class = "favnav"></button></a>

My JavaScript code looks like this:

window.onload = function() {
    var x =
        document.getElementsByClassName("favnav");

    var a = document.getElementsByTagName("a");

    for (var i = 0; i < x.length; ++i)

    {
        x.item(i).onmouseover = function(obj) {
            obj.target.style.backgroundColor = "rgb(0,106,106)";

            a.item(i).style.color = "rgb(0,128,128)";
        }
    }
}

The problem is that, I can see the effect in the button element on hover, but there is no change in the a elements text color text color. What's wrong? Please ignore any syntax error, I am typing the code by hand.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
user5241471
  • 105
  • 5

0 Answers0