折叠导航的实现方法有很多,在文本为大家介绍下如何使用js实现的折叠导航,感兴趣的朋友可以参考下
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv=content-type content="text/html; charset=utf-8" />
<link href="css/admin.css" type="text/css" rel="stylesheet" />
<script language=javascript>
function expand(el)//传递的是id,1,2,3用来区分所属的分类
{
childobj = document.getElementById("child" + el);//child1,child2.....
if (childobj.style.display == 'none')//如果此元素师none,就不会被显示
{
childobj.style.display = 'block';//如果是block。就会显示为块级元素
}
else
{
childobj.style.display = 'none';//当再次点击时,那么就会又隐藏起来
}
return;
}
</script>
</head>
<body>
<table height="100%" cellspacing=0 cellpadding=0 width=170
background=./img/menu_bg.jpg border=0>
<tr>
<td valign=top align=middle>
<table cellspacing=0 cellpadding=0 width="100%" border=0>
<tr>
<td height=10></td>
</tr>
</table>
<table cellspacing=0 cellpadding=0 width=150 border=0>
<tr height=22>
<td style="padding-left: 30px" background=./img/menu_bt.jpg>
<a class=menuparent οnclick=expand(1) href="javascript:void(0);">人员管理</a></td></tr>
<tr height=4>
<td></td></tr></table>
<table id=child1 style="display: none" cellspacing=0 cellpadding=0
width=150 border=0>
<tr height=20>
<td align=middle width=30><img height=9
src="./img/menu_icon.gif" width=9></td>
<td><a class=menuchild
href="memberadd.jsp"
target=right>人员增加</a></td></tr>
<tr height=20>
<td align=middle width=30><img height=9
src="./img/menu_icon.gif" width=9></td>
<td><a class=menuchild
href="#"
target=right>人员修改</a></td></tr>
<tr height=20>
<td align=middle width=30><img height=9
src="./img/menu_icon.gif" width=9></td>
<td><a class=menuchild
href="#"
target=right>人员删除</a></td></tr>
<tr height=20>
<td align=middle width=30><img height=9
src="./img/menu_icon.gif" width=9></td>
<td><a class=menuchild
href="#"
target=right>人员查找</a></td></tr>
<tr height=4>
<td colspan=2></td>
</tr>
</table>
</body>
</html>
<html>
<head>
<meta http-equiv=content-type content="text/html; charset=utf-8" />
<link href="css/admin.css" type="text/css" rel="stylesheet" />
<script language=javascript>
function expand(el)//传递的是id,1,2,3用来区分所属的分类
{
childobj = document.getElementById("child" + el);//child1,child2.....
if (childobj.style.display == 'none')//如果此元素师none,就不会被显示
{
childobj.style.display = 'block';//如果是block。就会显示为块级元素
}
else
{
childobj.style.display = 'none';//当再次点击时,那么就会又隐藏起来
}
return;
}
</script>
</head>
<body>
<table height="100%" cellspacing=0 cellpadding=0 width=170
background=./img/menu_bg.jpg border=0>
<tr>
<td valign=top align=middle>
<table cellspacing=0 cellpadding=0 width="100%" border=0>
<tr>
<td height=10></td>
</tr>
</table>
<table cellspacing=0 cellpadding=0 width=150 border=0>
<tr height=22>
<td style="padding-left: 30px" background=./img/menu_bt.jpg>
<a class=menuparent οnclick=expand(1) href="javascript:void(0);">人员管理</a></td></tr>
<tr height=4>
<td></td></tr></table>
<table id=child1 style="display: none" cellspacing=0 cellpadding=0
width=150 border=0>
<tr height=20>
<td align=middle width=30><img height=9
src="./img/menu_icon.gif" width=9></td>
<td><a class=menuchild
href="memberadd.jsp"
target=right>人员增加</a></td></tr>
<tr height=20>
<td align=middle width=30><img height=9
src="./img/menu_icon.gif" width=9></td>
<td><a class=menuchild
href="#"
target=right>人员修改</a></td></tr>
<tr height=20>
<td align=middle width=30><img height=9
src="./img/menu_icon.gif" width=9></td>
<td><a class=menuchild
href="#"
target=right>人员删除</a></td></tr>
<tr height=20>
<td align=middle width=30><img height=9
src="./img/menu_icon.gif" width=9></td>
<td><a class=menuchild
href="#"
target=right>人员查找</a></td></tr>
<tr height=4>
<td colspan=2></td>
</tr>
</table>
</body>
</html>