1 <script type="text/javascript">
2 var mymenu=function(id,speed){
3 if(this===window)
4 return new mymenu(id,speed);
5 var obj=document.getElementById(id),
6 childs=obj.childNodes[1].childNodes;
7 this.author="NoThinkingGao";
8 this.menuList=childs;
9 this.menuNume=childs.length;
10 this.currentIndex=0;
11 this.speed=speed||5000;
12 this.width=100;
13 this.runHandler=null;
14 this.len=this.menuNume;
15 }
16
17 mymenu.prototype={
18 bindMouse:function(){
19 for(var i=0;i<this.len;i++){
20 this.menuList[i].onmouseover=function(i){
21 this.menuList[1].style.border="1px solid red"; //上边这行为什么总是不对呢?TypeError: this.menuList is undefined
22 };
23 }
24 },
25 action:function(i){
26 window.alert(this.author+i);
27 },
28 play:function(){
29 window.alert(this.author);
30 },
31
32 changeback:function(){
33 this.menuList[1].style.border="1px solid red";
34 }
35 };
36 window.onload=function(){
37 mymenu("mymenu").bindMouse();
38 mymenu("mymenu").changeback();
39 };
40 </script>
1 回答
HUH函数
TA贡献1836条经验 获得超4个赞
把 this.menuList[1].style.border="1px solid red";
改成 this.style.border="1px solid red";试试。。
添加回答
举报
0/150
提交
取消