猿问

onmouseover事件问题?

代码如下:

<script>


    function ChangeColor(id,color) {

        this.colorChangeOver = function (){

            document.getElementById(this.id).style.backgroundColor = this.color;

        }

    }

    var color1 = new ChangeColor(document.getElementsByTagName("li")[0].id,"blue");

    var color2 = new ChangeColor(document.getElementsByTagName("li")[1].id,"green");

    var color3 = new ChangeColor(document.getElementsByTagName("li")[2].id,"red");

</script>


<body>



            <li id="nav1" onmouseover="color1.colorChangeOver()" ><a href="#">###</a></li>

            <li id="nav2" onmouseover="color2.colorChangeOver()" ><a href="#">###</a></li>

            <li id="nav3" onmouseover="color3.colorChangeOver()" ><a href="#">###</a></li>

</body>


为何事件没有被触发,是哪里出问题了吗?


慕勒3428872
浏览 418回答 1
1回答
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答