js渐入渐出效果没有

有没有哪位跟着老师的步骤走但是没有渐入渐出效果的?而是直接就跳出来的?汇报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>


盏中柳色浅
浏览 1884回答 2
2回答

浅水了

u.id    id怎么来的?

浅水了

setTimeout(addH('"+id+"'),10); 应该是这句错了吧setTimeout(addH(”'"+id+"'“),10)
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript