日期:2014-05-16  浏览次数:20478 次

javascript树形菜单的一点问题!
我想做一个树形菜单,有3个类似的页面,第一个页面打开后,展开的是第一个折叠的菜单(同事),其他的都收起来;第二个打开,展开第二个折叠菜单(客户),其他的也收起来;  
 我找到类似的代码,但是改不到我想要的效果。请大家帮帮忙!给出改好我要的结果的代码,谢谢!
 

<!doctype html public "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<head>
<title>适合放在网站右侧的CSS二级树形菜单_网页代码站(www.webdm.cn)</title>
<style type="text/css" media="all">
a,a:visited {color:#333;text-decoration:none;}
a:hover {color:#f60;}
body,td {font:13px "Geneva","宋体", "Arial", "Helvetica",sans-serif;}
ul,li {margin:0;padding:0;list-style:none;}
h1,h2,h3,h4,h5,h6 {margin:0;padding:0;}
h1 {padding:5px;color:#900;font:16px bold "Geneva","宋体", "Arial", "Helvetica",sans-serif;}
h1 small {font-size:11px;font-weight:normal;color:#660;}
.TreeWrap {width:200px;}
.MenuBox .titBox a,
.MenuBox .titBox a:visited,
.MenuBox2 .titBox a,
.MenuBox2 .titBox a:visited {margin-left:10px;padding-left:40px;color:#003;font-size:12px;display:block;}
.MenuBox .titBox h3 a {background:url(http://www.webdm.cn/images/20101124/1/ico_folder_open.gif) no-repeat 0 40%;}
.MenuBox .titBox h3.Fst a {background:url(http://www.webdm.cn/images/20101124/1/ico_folder_open_fst.gif) no-repeat 0 40%;}
.MenuBox .titBox h3.Lst a {background:url(http://www.webdm.cn/images/20101124/1/ico_folder_open_lst.gif) no-repeat 0 40%;}
.MenuBox2 .titBox h3 a {background:url(http://www.webdm.cn/images/20101124/1/ico_folder.gif) no-repeat 0 40%;}
.MenuBox2 .titBox h3.Fst a {background:url(http://www.codefans.net/jscss/demoimg/201010/ico_folder_fst.gif) no-repeat 0 40%;}
.MenuBox2 .titBox h3.Lst a {line-height:250%;background:url(http://www.webdm.cn/images/20101124/1/con_exit.gif) no-repeat 0 0;}
.MenuBox2 .txtBox {display:none;}
.MenuBox .txtBox ul li {padding-left:65px;line-height:150%;}
.MenuBox .txtBox .num {color:#e00;}
.MenuBox .txtBox ul {background:url(http://www.webdm.cn/images/20101124/1/line_y.gif) repeat-y 16px 0;}
.MenuBox .txtBox ul li {background:url(http://www.webdm.cn/images/20101124/1/t.gif) no-repeat 28px 50%;}
.MenuBox .txtBox ul li.Lst {background:url(http://www.webdm.cn/images/20101124/1/t_lst.gif) no-repeat 28px 50%;}
</style>
<script type="text/javascript">
 <!--
 function ExChgClsName(Obj,NameA,NameB){
  var Obj=document.getElementById(Obj)?document.getElementById(Obj):Obj;
  Obj.className=Obj.className==NameA?NameB:NameA;
 }
 function showMenu(iNo){
 ExChgClsName("Menu_"+iNo,"MenuBox","MenuBox2");
 }
-->
</script>
</head>
<body>
<div class="TreeWrap">
<div class="MenuBox" id="Menu_0">
<div class="titBox"><h3><a href="javascript:showMenu(0);">同事</a></h3></div>
<div class="txtBox">
 <ul>
  <li><a href="#">Dodo</a></li>
  <li><a href="#">小春</a></li>
  <li><a href="#">小林</a></li>
  <li><a&nb