falut.html:34 Uncaught TypeError: Cannot read property 'offsetHeight' of null 代码如下,浏览器一直提示错误,如何修改?跪求解决方法
<!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">
*{ margin:0px; padding:0px;}
body{ font-family:Verdana, Geneva, sans-serif; font-size:14px;}
#nav{ width:600px; height:40px; background-color:#eee; margin:0 auto;}
ul{ list-style:none;}
ul li{ float:left; line-height:40px; text-align:center; width:100px;}
a{ text-decoration:none; color:#000; display:block;}
a:hover{ color:#F00; background-color:#666;}
ul li ul li{ float:none;background-color:#eee; margin:2px 0px; position:relative;}
ul li ul li ul{
position:absolute;top:0px; left:100px;}
ul li ul{ display:none; }
</style>
<script type="text/javascript">
window.onload=function(){
var lis=document.getElementsByTagName("li");
for (var i=0;i<lis.length;i++){
lis[i].onmousemove=function(){
var ul=this.getElementsByTagName("ul")[0];
if(ul!=undefined){
ul.style.display="block";
changeH(ul.id,1)
}}
}}
function changeH(id,count){
var lisul=document.getElementById("id");
var h=lisul.offsetHeight;
h+=count;
if(count>0)
{
if(h<=120){
lisul.style.height=h+"px";
setTimeout("changeH('"+id+"')",10);
}
else{
return;}
}
}
</script>
</head>
<body>
<div id="nav">
<ul>
<li><a href="#">首页</a></li>
<li><a href="#">课程大厅</a>
<ul>
<li><a href="#">前端课程</a>
</li>
<li><a href="#">手机开发</a></li>
<li><a href="#">后台编程</a></li>
</ul>
</li>
<li><a href="#">学习中心</a>
<ul>
<li><a href="#">视频学习</a></li>
<li><a href="#">实例练习</a></li>
<li><a href="#">问与答</a></li>
</ul>
</li>
<li><a href="#">经典案例</a></li>
<li><a href="#">关于我们</a></li>
</ul>
</div>
</body>
</html>