欢迎来到Java学习网!
设为首页 | 加入收藏
当前位置: 首页 > Java语言 > JavaScript >

JS无限级树形菜单源代码 - Java中文网:http://www.javaweb.cc/ 编辑整理

无限级树形菜单,效果不错。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
a {text-decoration:none;}
a,a:visited {color:#000;background:inherit;}
body {margin:0;padding:20px;font:12px tahoma,宋体,sans-serif;}
dt {font-size:22px;font-weight:bold;margin:0 0 0 15px;}
dd {margin:0 0 0 15px;}
h4 {margin:0;padding:0;font-size:18px;text-align:center;}
p {margin:0;padding:0 0 0 18px;}
p a,p a:visited {color:#00f;background:inherit;}
/*CNLTreeMenu Start*/
.CNLTreeMenu img.s {cursor:pointer;vertical-align:middle;}
.CNLTreeMenu ul {padding:0;}
.CNLTreeMenu li {list-style:none;padding:0;}
.Closed ul {display:none;}
.Child img.s {background:none;cursor:default;}
#CNLTreeMenu1 ul {margin:0 0 0 17px;}
#CNLTreeMenu1 img.s {width:20px;height:15px;}
#CNLTreeMenu1 .Opened img.s {background:url(http://www.zzsky.cn/effect/images/treemenu/opened1.gif) no-repeat 0 0;}
#CNLTreeMenu1 .Closed img.s {background:url(http://www.zzsky.cn/effect/images/treemenu/closed1.gif) no-repeat 0 0;}
#CNLTreeMenu1 .Child img.s {background:url(http://www.zzsky.cn/effect/images/treemenu/child1.gif) no-repeat 3px 5px;}
#CNLTreeMenu2 ul {margin:0 0 0 17px;}
#CNLTreeMenu2 img.s {width:17px;height:15px;}
#CNLTreeMenu2 .Opened img.s {background:url(http://www.zzsky.cn/effect/images/treemenu/opened2.gif) no-repeat 4px 6px;}
#CNLTreeMenu2 .Closed img.s {background:url(http://www.zzsky.cn/effect/images/treemenu/closed2.gif) no-repeat 3px 6px;}
#CNLTreeMenu2 .Child img.s {background:url(http://www.zzsky.cn/effect/images/treemenu/child2.gif) no-repeat 3px 5px;}
#CNLTreeMenu3 ul {margin:0 0 0 17px;}
#CNLTreeMenu3 img.s {width:34px;height:18px;}
#CNLTreeMenu3 .Opened img.s {background:url(http://www.zzsky.cn/effect/images/treemenu/opened3.gif) no-repeat 0 1px;}
#CNLTreeMenu3 .Closed img.s {background:url(http://www.zzsky.cn/effect/images/treemenu/closed3.gif) no-repeat 0 1px;}
#CNLTreeMenu3 .Child img.s {background:url(http://www.zzsky.cn/effect/images/treemenu/child3.gif) no-repeat 13px 2px;}
/*CNLTreeMenu End*/
/*Temp CSS for View Demo*/
#CNLTreeMenu1,#CNLTreeMenu2,#CNLTreeMenu3 {float:left;width:249px;border:1px solid #99BEEF;background:#D2E4FC;color:inherit;margin:3px;padding:3px;}
#CNLTreeMenu1,#CNLTreeMenu2 {padding-bottom:15px;}
.ViewCode {clear:both;border:1px solid #FFB900;background:#FFFFCC;color:inherit;margin:3px;padding:3px;}
.ViewCode h6 {color:#00f;}
</style>
<title>无限级树形菜单- java中文网:www.javaweb.cc</title>
</head>
<body>
<div class="CNLTreeMenu" id="CNLTreeMenu1">
<h4>CNL Tree Menu1</h4>
<p><a id="AllOpen_1" href="#" onClick="MyCNLTreeMenu1.SetNodes(0);Hd(this);Sw('AllClose_1');">全部展开</a><a id="AllClose_1" href="#" onClick="MyCNLTreeMenu1.SetNodes(1);Hd(this);Sw('AllOpen_1');" style="display:none;">全部折叠</a></p>
<ul>
<li class="Opened"><a href="http://www.zzsky.cn">Zzsky.Cn</a>
<ul>
<li><a href="#1">技术区</a>
<ul>
<li><a href="#">网页技术</a>
<ul>
<li class="Child"><a href="#">JavaScript</a></li>
<!--Child Node-->
<li class="Child"><a href="#">HTML/XHTML/CSS</a></li>
<li class="Child"><a href="#">Ajax</a></li>
<li class="Child"><a href="#">网页制作工具</a></li>
<li class="Child"><a href="#">设计/图形</a></li>
<li class="Child"><a href="#">Flash/多媒体</a></li>
<li class="Child"><a href="#">VML/Web3D</a></li>
</ul>
</li>

相关教程
推荐内容