javaScript无限级菜单
<!doctype html>
<html>
<head>
<style type="text/css">
*{margin:0;padding:0;}
ul{list-style:none;display:none}
ul ul{list-style:none;position:absolute;left:100px;top:0;display:none}
.menu{float:left;width:100px;margin-right:15px}
li{width:100px;position:relative;background:orange;border-bottom:1px solid #fff}
</style>
</head>
<body>
<div id="menu1" class="menu">
<h3>ssssssss</h3>
<div class="position">
<ul>
<li>1111111</li>
<li>1111111
<ul>
<li>1111111</li>
<li>1111111
<ul>
<li>1111111</li>
<li>1111111
<ul>
<li>1111111</li>
<li>1111111
<ul>
<li>1111111</li>
<li>1111111</li>
<li>1111111</li>
<li>1111111</li>
<li>1111111</li>
</ul>
</li>
<li>1111111</li>
<li>1111111</li>
<li>1111111</li>
</ul>
</li>
<li>1111111</li>
<li>1111111</li>
<li>1111111</li>
</ul>
</li>
<li>1111111</li>
<li>1111111</li>
<li>1111111</li>
</ul>
</li>
<li>1111111</li>
<li>1111111</li>
<li>1111111</li>
</ul>
</div>
</div>
<div id="menu2" class="menu">
<h3>ssssssss</h3>
<div class="position">
<ul>
<li>1111111</li>
<li>1111111</li>
<li>1111111</li>
<li>1111111</li>
<li>1111111</li>
</ul>
</div>
</div>
<script type="text/javascript">
var $ = function(id){return document.getElementById(id)}
for(var i=1; i<=2; i++){
var menu = $("menu"+i);
type()
}
function type(){
var menuh3 = menu.getElementsByTagName("h3");
var menuul = menu.getElementsByTagName("ul");
var menuli = menuul[0].getElementsByTagName("li");
menuh3[0].onmouseover = show;
menuh3[0].onmouseout = hide;
menuul[0].onmouseover = show;
menuul[0].onmouseout = hide;
function show(){
menuul[0].style.display = "block";
}
function hide(){
menuul[0].style.display = "none";
}
for(var i=0; i<menuli.length; i++){
var li = menuli[i].getElementsByTagName("ul")[0];
if(li){
run();
}
}
function run(){
menuli[i].onmouseover = showul;
menuli[i].onmouseout = unshowul;
}
function showul(){
this.getElementsByTagName("ul")[0].style.display = "block";
}
function unshowul(){
this.getElementsByTagName("ul")[0].style.display = "none";
}
}
</script>
</body>
</html>