代码如下:
<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>
为何事件没有被触发,是哪里出问题了吗?
相关分类