有没有哪位跟着老师的步骤走但是没有渐入渐出效果的?而是直接就跳出来的?汇报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>
添加回答
举报
0/150
提交
取消