单击收缩菜单,每次只打开一个菜单

.menuParent {
font-size: 12px;
width: 145px;
font-weight: bold;
display:block;
height: 33px;
padding-top:7px;
vertical-align :middle ;
}
.menuParent a
{
text-decoration: none;
}
.menuParent a:hover {
font-size: 12px;
color: #FFFFFF;
width: 145px;
font-weight: bold;
text-decoration: none;
height: 33px;
padding-top:7px;
vertical-align :middle ;
}
--单击收缩菜单,每次只打开一个菜单
<script language="javascript">
function expand(el, length) {
for (var i = 0; i < length; i++) {
childObj = document.getElementById("child" + i);
if (i == el && childObj.style.display == 'none') {
childObj.style.display = 'block';
}
else {
childObj.style.display = 'none';
}
}
}
</script>
--后台动态生成两级菜单,调用JS方法实现菜单收缩
<a href=\"javascript:void(0)\" class=menuParent onclick=expand(" + j + "," + list.Count + ") >" + list[j].MenuName + "</a>
浙公网安备 33010602011771号