<!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=gb2312" />
<title>无标题文档</title>
<style>
div{float:left; margin:10px;}
#div1{background:#0099CC; width:80px; height:100px;}
#div2{background:#0099CC; width:100px; height:300px; display:none;}
</style>
<script>
window.onload = function(){
var oDi1 = document.getElementById("div1");
var oDi2 = document.getElementById("div2");
var timer = null; //把定时器用变量存起来
oDi1.onmouseover = oDi2.onmouseover = function(){
clearTimeout(timer);
oDi2.style.display = "block";
}
oDi1.onmouseout = oDi2.onmouseout = function(){
timer = setTimeout(function(){
oDi2.style.display = "none";
},500);
}
}
</script>
</head>
<body>
<div id="div1">一级列表</div>
<div id="div2">二级列表</div>
</body>
</html>
我以为上下级列表是要用什么东西连接起来的,实际上它们是完全独立的两套div,只是可能会调用相同的属性。