下拉菜单收不回去了,我是新手菜鸟,求大神帮忙改好发我看看,出主意的我真的看不懂QAQ,谢谢了】
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>树形菜单</title>
<style>
*{ margin:0; padding:0}
ul{ list-style:none}
a{ text-decoration:none}
li a{ display:block; height:30px;line-height:30px; font-size:14px; color:#999; padding-left:2em}
.subMenu{ display:none; margin-left:1em}
.hasSub>a{ display:block; background-image:url(a1.png); background-repeat:no-repeat; background-position:10px center;color:#666}
.showSubmenu>a{ background-image:url(a2.png); background-position:11px center; background-repeat:no-repeat}
.ac{ color:#000 !important; background-color:#efefef;}
#objTree{ margin:100px; width:260px; padding:10px; border:1px solid #777}
</style>
</head>
<body>
<div id="objTree">
<ul class="tree">
<li> <a href="javascript:;">一级菜单</a>
<!--二级--------------------------->
<ul>
<li><a href="javascript:;">二级菜单</a>
<!--三级--------------------------->
<ul>
<li><a href="javascript:;">三级菜单</a></li>
</ul>
<!--三级--------------------------->
</li>
</ul>
<!--二级--------------------------->
</li>
</ul>
</div>
</body>
</html>
<script>
var li=document.getElementsByTagName("li");
for(var i=0;i<li.length;i++){
var ul=li[i].getElementsByTagName("ul")[0];
if(ul){
ul.className="subMenu";
li[i].className="hasSub";
}
li[i].onclick=function(){
var oul=this.getElementsByTagName("ul")[0];
oul.style.display="block";
};
}
</script>
筱汐
相关分类