首页 新闻 会员 周边

在学js时遇到小问题,求解答

0
悬赏园豆:5 [已解决问题] 解决于 2012-10-02 11:06
 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>
高明无思的主页 高明无思 | 初学一级 | 园豆:6
提问于:2012-10-01 12:53
< >
分享
最佳答案
1

把   this.menuList[1].style.border="1px solid red";
改成 this.style.border="1px solid red";试试。。

收获园豆:5
DXAndLIGHT | 菜鸟二级 |园豆:206 | 2012-10-01 17:34

You are right,thank you!

高明无思 | 园豆:6 (初学一级) | 2012-10-02 11:06
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册