subH没有效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
#nav{font-size:12px;font-weight:bold;list-style:none;overflow:auto;}
#nav li{float:left;margin-right:1px;}
#nav li a{line-height:20px;text-decoration:none;background:#CCCCCC;color:#333333;width:80px;text-align:center;display:block;}
#nav li ul{display:none;list-style:none;padding:0;position:relative;height:0;overflow:hidden;}
#nav li a:hover{color:#FFFFFF;}
</style>
</head>
<body>
<ul id="nav">
<li><a href="#">首页</a></li>
<li><a href="#">课程大厅</a></li>
<li><a href="#">学习中心+</a>
<ul id="a">
<li><a href="#">前端开发</a>
<ul>
<li><a href="#">JavaScript</a></li>
<li><a href="#">jqery</a></li>
<li><a href="#">css</a></li>
</ul>
</li>
<li><a href="#">时间开发</a></li>
<li><a href="#">后天编程</a></li>
</ul>
</li>
<li><a href="#">关于我们</a></li>
</ul>
<script>
var timer;
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];
u.style.display='block';
AddH('a');
}
lis[i].onmouseout=function(){
var u=this.getElementsByTagName('ul')[0];
SubH('a');
}
}
}
function AddH(id){
var ullist=document.getElementById(id);
setInterval(function(){
if(ullist.offsetHeight>=34){
return;
}else{
ullist.style.height=ullist.offsetHeight+1+'px';
}
},10);
}
function SubH(id){
var ullist=document.getElementById(id);
setInterval(function(){
if(ullist.offsetHeight>0){
ullist.style.height=ullist.offsetHeight-1+'px';
}else{
ullist.style.display='none';
return;
}
},10);
}
</script>
</body>
</html>
如题,addH可以展开,但是subH收不回去,调试也不知道错哪里