为了账号安全,请及时绑定邮箱和手机立即绑定

js渐入渐出效果没有

js渐入渐出效果没有

盏中柳色浅 2015-07-14 11:56:14
有没有哪位跟着老师的步骤走但是没有渐入渐出效果的?而是直接就跳出来的?汇报addH not defined的错 <script>         window.onload=function(){             var Lis=document.getElementsByTagName('li');            for(var i=0;i<Lis.length;i++){                Lis[i].onmouseover=function(){                    var u=this.getElementsByTagName('ul')[0];                   // console.log(u);                    if(u != undefined){                        u.style.display=' block';                        addH(u.id);                    }                    Lis[i].onmouseleave=function(){                         var u=this.getElementsByTagName('ul')[0];                         if(u != undefined){                             u.style.display='none';                             subH(u.id);                         }                }                }            }             function addH(id){                 var ulList=document.getElementById(id);                 var h=ulList.offsetHeight;                 h+=1;                 if(h <= 42){                     ulList.style.height=h+'px';                     setTimeout(addH('"+id+"'),10);                     debugger;                     /* debugger;                      addH(id);*/                 }                 else{                     return;                 }             }             function subH(id){                 var ulList=document.getElementById(id);                 var h=ulList.offsetHeight;                 h-=1;                 if(h > 0){                     ulList.style.height=h+'px';                     setTimeout(subH('"+id+"'),10);                 }             }         }     </script> </head> <body>     <!-- 代码 开始 -->     <div id="menu">         <ul id="nav">             <li class="mainlevel"><span class="note">慕课网</span></li>             <li class="mainlevel" id="mainlevel_01"><a href="#">课程大厅</a>                 <ul class="sub_nav_01" id="iTest">                     <span class="Triangle_con"></span>                     <li ><a href="#">JavaScript</a></li>                     <li><a href="#">JQuery</a></li>                     <li><a href="#">HTML</a></li>                 </ul>             </li>             <li class="mainlevel" id="mainlevel_02"><a href="#">学习中心</a>                 <!--<ul class="sub_nav_01">                     <span class="Triangle_con"></span>                     <li><a href="#">JavaScript</a></li>                     <li><a href="#">HTML</a></li>                 </ul>-->             </li>             <li class="mainlevel"><a href="#">个人中心</a></li>             <li class="mainlevel"><a href="#">关于我们</a></li>         </ul>     </div>
查看完整描述

2 回答

?
浅水了

TA贡献12条经验 获得超2个赞

u.id    id怎么来的?


查看完整回答
反对 回复 2015-07-20
  • 盏中柳色浅
    盏中柳色浅
    id是元素u的id值,是个字符串,但是在递归调用的时候穿不进addH里面
?
浅水了

TA贡献12条经验 获得超2个赞

setTimeout(addH('"+id+"'),10); 应该是这句错了吧setTimeout(addH(”'"+id+"'“),10)

查看完整回答
反对 回复 2015-07-15
  • 2 回答
  • 0 关注
  • 1875 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信