無限級樹形菜單
[重要通告]如您遇疑難雜癥,本站支持知識付費(fèi)業(yè)務(wù),掃右邊二維碼加博主微信,可節(jié)省您寶貴時(shí)間哦!
無限級樹形菜單
演示:http://www.zzsky.cn/effect/content/1047.htm
代碼:
代碼:
<html>
<head>
<title>中國站長天空-網(wǎng)頁特效-導(dǎo)航菜單-無限級樹形菜單</title>
<meta http-equiv="content-Type" content="text/html;charset=gb2312">
<!--把下面代碼加到<head>與</head>之間-->
<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/files/treemenu/opened1.gif) no-repeat 0 0;}
#CNLTreeMenu1 .Closed img.s {background:url(http://www.zzsky.cn/effect/files/treemenu/closed1.gif) no-repeat 0 0;}
#CNLTreeMenu1 .Child img.s {background:url(http://www.zzsky.cn/effect/files/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/files/treemenu/opened2.gif) no-repeat 4px 6px;}
#CNLTreeMenu2 .Closed img.s {background:url(http://www.zzsky.cn/effect/files/treemenu/closed2.gif) no-repeat 3px 6px;}
#CNLTreeMenu2 .Child img.s {background:url(http://www.zzsky.cn/effect/files/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/files/treemenu/opened3.gif) no-repeat 0 1px;}
#CNLTreeMenu3 .Closed img.s {background:url(http://www.zzsky.cn/effect/files/treemenu/closed3.gif) no-repeat 0 1px;}
#CNLTreeMenu3 .Child img.s {background:url(http://www.zzsky.cn/effect/files/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>
</head>
<body>
<!--把下面代碼加到<body>與</body>之間-->
<!--CNLTreeMenu Start:-->
<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">技術(shù)區(qū)</a>
<ul>
<li><a href="#">網(wǎng)頁技術(shù)</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="#">網(wǎng)頁制作工具</a></li>
<li class="Child"><a href="#">設(shè)計(jì)/圖形</a></li>
<li class="Child"><a href="#">Flash/多媒體</a></li>
<li class="Child"><a href="#">VML/Web3D</a></li>
</ul></li><!--Sub Node 3-->
<li><a href="#">Web編程</a>
<ul>
<li class="Child"><a href="#">Java</a></li><!--Child Node-->
<li class="Child"><a href="#">.Net</a></li>
<li class="Child"><a href="#">ASP/VBScript</a></li>
<li class="Child"><a href="#">PHP</a></li>
<li class="Child"><a href="#">Perl/Python</a></li>
<li class="Child"><a href="#">Web綜合/開源</a></li>
</ul></li><!--Sub Node 3-->
<li><a href="#">數(shù)據(jù)庫</a>
<ul>
<li class="Child"><a href="#">Access/SQLServer</a></li><!--Child Node-->
<li class="Child"><a href="#">MySQL/PostgreSQL</a></li>
<li class="Child"><a href="#">Oracle/DB2/Sybase</a></li>
</ul></li><!--Sub Node 3-->
<li><a href="#">服務(wù)器</a>
<ul>
<li class="Child"><a href="#">Windows/IIS</a></li><!--Child Node-->
<li class="Child"><a href="#">Unix/Linux/Apache</a></li>
<li class="Child"><a href="#">應(yīng)用服務(wù)器</a></li>
</ul></li><!--Sub Node 3-->
</ul></li><!--Sub Node 2-->
<li><a href="#1">二級目錄</a>
<ul>
<li><a href="#">三級目錄</a>
<ul>
<li><a href="#">四級目錄</a>
<ul>
<li><a href="#">五級目錄</a>
<ul>
<li><a href="#">......</a>
<ul>
<li><a href="#">第n級目錄</a>
<ul>
<li class="Child"><a href="#">葉結(jié)點(diǎn)1</a></li><!--Child Node-->
<li class="Child"><a href="#">葉結(jié)點(diǎn)2</a></li>
<li class="Child"><a href="#">葉結(jié)點(diǎn)3</a></li>
</ul></li><!--Sub Node n -->
</ul></li><!--Sub Node 6 -->
</ul></li><!--Sub Node 5 -->
</ul></li><!--Sub Node 4-->
</ul></li><!--Sub Node 3-->
</ul></li><!--Sub Node 2-->
<li><a href="#1">二級目錄</a>
<ul>
<li><a href="#">三級目錄</a>
<ul>
<li><a href="#">四級目錄</a>
<ul>
<li><a href="#">五級目錄</a>
<ul>
<li><a href="#">......</a>
<ul>
<li><a href="#">第n級目錄</a>
<ul>
<li class="Child"><a href="#">葉結(jié)點(diǎn)1</a></li><!--Child Node-->
<li class="Child"><a href="#">葉結(jié)點(diǎn)2</a></li>
<li class="Child"><a href="#">葉結(jié)點(diǎn)3</a></li>
</ul></li><!--Sub Node n -->
</ul></li><!--Sub Node 6 -->
</ul></li><!--Sub Node 5 -->
</ul></li><!--Sub Node 4-->
</ul></li><!--Sub Node 3-->
</ul></li><!--Sub Node 2-->
</ul></li><!--Sub Node 1 -->
</ul>
</div><!-- CNLTreeMenu -->
<!--CNLTreeMenu1 End!-->
<!--CNLTreeMenu2 Start:-->
<div class="CNLTreeMenu" id="CNLTreeMenu2">
<h4>CNL Tree Menu2</h4>
<p><a id="AllOpen_2" href="#" onclick="MyCNLTreeMenu2.SetNodes(0);Hd(this);Sw('AllClose_2');">全部展開</a><a id="AllClose_2" href="#" onclick="MyCNLTreeMenu2.SetNodes(1);Hd(this);Sw('AllOpen_2');" style="display:none;">全部折疊</a></p>
<ul>
<li class="Opened"><a href="http://www.zzsky.cn">Zzsky.Cn</a>
<ul>
<li><a href="#1">技術(shù)區(qū)</a>
<ul>
<li><a href="#">網(wǎng)頁技術(shù)</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="#">網(wǎng)頁制作工具</a></li>
<li class="Child"><a href="#">設(shè)計(jì)/圖形</a></li>
<li class="Child"><a href="#">Flash/多媒體</a></li>
<li class="Child"><a href="#">VML/Web3D</a></li>
</ul></li><!--Sub Node 3-->
<li><a href="#">Web編程</a>
<ul>
<li class="Child"><a href="#">Java</a></li><!--Child Node-->
<li class="Child"><a href="#">.Net</a></li>
<li class="Child"><a href="#">ASP/VBScript</a></li>
<li class="Child"><a href="#">PHP</a></li>
<li class="Child"><a href="#">Perl/Python</a></li>
<li class="Child"><a href="#">Web綜合/開源</a></li>
</ul></li><!--Sub Node 3-->
<li><a href="#">數(shù)據(jù)庫</a>
<ul>
<li class="Child"><a href="#">Access/SQLServer</a></li><!--Child Node-->
<li class="Child"><a href="#">MySQL/PostgreSQL</a></li>
<li class="Child"><a href="#">Oracle/DB2/Sybase</a></li>
</ul></li><!--Sub Node 3-->
<li><a href="#">服務(wù)器</a>
<ul>
<li class="Child"><a href="#">Windows/IIS</a></li><!--Child Node-->
<li class="Child"><a href="#">Unix/Linux/Apache</a></li>
<li class="Child"><a href="#">應(yīng)用服務(wù)器</a></li>
</ul></li><!--Sub Node 3-->
</ul></li><!--Sub Node 2-->
<li><a href="#1">二級目錄</a>
<ul>
<li><a href="#">三級目錄</a>
<ul>
<li><a href="#">四級目錄</a>
<ul>
<li><a href="#">五級目錄</a>
<ul>
<li><a href="#">......</a>
<ul>
<li><a href="#">第n級目錄</a>
<ul>
<li class="Child"><a href="#">葉結(jié)點(diǎn)1</a></li><!--Child Node-->
<li class="Child"><a href="#">葉結(jié)點(diǎn)2</a></li>
<li class="Child"><a href="#">葉結(jié)點(diǎn)3</a></li>
</ul></li><!--Sub Node n -->
</ul></li><!--Sub Node 6 -->
</ul></li><!--Sub Node 5 -->
</ul></li><!--Sub Node 4-->
</ul></li><!--Sub Node 3-->
</ul></li><!--Sub Node 2-->
<li><a href="#1">二級目錄</a>
<ul>
<li><a href="#">三級目錄</a>
<ul>
<li><a href="#">四級目錄</a>
<ul>
<li><a href="#">五級目錄</a>
<ul>
<li><a href="#">......</a>
<ul>
<li><a href="#">第n級目錄</a>
<ul>
<li class="Child"><a href="#">葉結(jié)點(diǎn)1</a></li><!--Child Node-->
<li class="Child"><a href="#">葉結(jié)點(diǎn)2</a></li>
<li class="Child"><a href="#">葉結(jié)點(diǎn)3</a></li>
</ul></li><!--Sub Node n -->
</ul></li><!--Sub Node 6 -->
</ul></li><!--Sub Node 5 -->
</ul></li><!--Sub Node 4-->
</ul></li><!--Sub Node 3-->
</ul></li><!--Sub Node 2-->
</ul></li><!--Sub Node 1 -->
</ul>
</div><!-- CNLTreeMenu -->
<!--CNLTreeMenu2 End-->
<!--CNLTreeMenu3 Start:-->
<div class="CNLTreeMenu" id="CNLTreeMenu3">
<h4>CNL Tree Menu3</h4>
<p><a id="AllOpen_3" href="#" onclick="MyCNLTreeMenu3.SetNodes(0);Hd(this);Sw('AllClose_3');">全部展開</a><a id="AllClose_3" href="#" onclick="MyCNLTreeMenu3.SetNodes(1);Hd(this);Sw('AllOpen_3');" style="display:none;">全部折疊</a></p>
<ul>
<li class="Opened"><a href="http://www.zzsky.cn">Zzsky.Cn</a>
<ul>
<li><a href="#1">技術(shù)區(qū)</a>
<ul>
<li><a href="#">網(wǎng)頁技術(shù)</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="#">網(wǎng)頁制作工具</a></li>
<li class="Child"><a href="#">設(shè)計(jì)/圖形</a></li>
<li class="Child"><a href="#">Flash/多媒體</a></li>
<li class="Child"><a href="#">VML/Web3D</a></li>
</ul></li><!--Sub Node 3-->
<li><a href="#">Web編程</a>
<ul>
<li class="Child"><a href="#">Java</a></li><!--Child Node-->
<li class="Child"><a href="#">.Net</a></li>
<li class="Child"><a href="#">ASP/VBScript</a></li>
<li class="Child"><a href="#">PHP</a></li>
<li class="Child"><a href="#">Perl/Python</a></li>
<li class="Child"><a href="#">Web綜合/開源</a></li>
</ul></li><!--Sub Node 3-->
<li><a href="#">數(shù)據(jù)庫</a>
<ul>
<li class="Child"><a href="#">Access/SQLServer</a></li><!--Child Node-->
<li class="Child"><a href="#">MySQL/PostgreSQL</a></li>
<li class="Child"><a href="#">Oracle/DB2/Sybase</a></li>
</ul></li><!--Sub Node 3-->
<li><a href="#">服務(wù)器</a>
<ul>
<li class="Child"><a href="#">Windows/IIS</a></li><!--Child Node-->
<li class="Child"><a href="#">Unix/Linux/Apache</a></li>
<li class="Child"><a href="#">應(yīng)用服務(wù)器</a></li>
</ul></li><!--Sub Node 3-->
</ul></li><!--Sub Node 2-->
<li><a href="#1">二級目錄</a>
<ul>
<li><a href="#">三級目錄</a>
<ul>
<li><a href="#">四級目錄</a>
<ul>
<li><a href="#">五級目錄</a>
<ul>
<li><a href="#">......</a>
<ul>
<li><a href="#">第n級目錄</a>
<ul>
<li class="Child"><a href="#">葉結(jié)點(diǎn)1</a></li><!--Child Node-->
<li class="Child"><a href="#">葉結(jié)點(diǎn)2</a></li>
<li class="Child"><a href="#">葉結(jié)點(diǎn)3</a></li>
</ul></li><!--Sub Node n -->
</ul></li><!--Sub Node 6 -->
</ul></li><!--Sub Node 5 -->
</ul></li><!--Sub Node 4-->
</ul></li><!--Sub Node 3-->
</ul></li><!--Sub Node 2-->
<li><a href="#1">二級目錄</a>
<ul>
<li><a href="#">三級目錄</a>
<ul>
<li><a href="#">四級目錄</a>
<ul>
<li><a href="#">五級目錄</a>
<ul>
<li><a href="#">......</a>
<ul>
<li><a href="#">第n級目錄</a>
<ul>
<li class="Child"><a href="#">葉結(jié)點(diǎn)1</a></li><!--Child Node-->
<li class="Child"><a href="#">葉結(jié)點(diǎn)2</a></li>
<li class="Child"><a href="#">葉結(jié)點(diǎn)3</a></li>
</ul></li><!--Sub Node n -->
</ul></li><!--Sub Node 6 -->
</ul></li><!--Sub Node 5 -->
</ul></li><!--Sub Node 4-->
</ul></li><!--Sub Node 3-->
</ul></li><!--Sub Node 2-->
</ul></li><!--Sub Node 1 -->
</ul>
</div><!-- CNLTreeMenu -->
<!--CNLTreeMenu3 End-->
<script type="text/javascript">
<!--
function Ob(o){
var o=document.getElementById(o)?document.getElementById(o):o;
return o;
}
function Hd(o) {
Ob(o).style.display="none";
}
function Sw(o) {
Ob(o).style.display="";
}
function ExCls(o,a,b,n){
var o=Ob(o);
for(i=0;i<n;i++) {o=o.parentNode;}
o.className=o.className==a?b:a;
}
function CNLTreeMenu(id,TagName0) {
this.id=id;
this.TagName0=TagName0==""?"li":TagName0;
this.AllNodes = Ob(this.id).getElementsByTagName(TagName0);
this.InitCss = function (ClassName0,ClassName1,ClassName2,ImgUrl) {
this.ClassName0=ClassName0;
this.ClassName1=ClassName1;
this.ClassName2=ClassName2;
this.ImgUrl=ImgUrl || "http://www.zzsky.cn/effect/files/treemenu/s.gif";
this.ImgBlankA ="<img src=\""+this.ImgUrl+"\" class=\"s\" onclick=\"ExCls(this,'"+ClassName0+"','"+ClassName1+"',1);\" alt=\"展開/折疊\" />";
this.ImgBlankB ="<img src=\""+this.ImgUrl+"\" class=\"s\" />";
for (i=0;i<this.AllNodes.length;i++ ) {
this.AllNodes[i].className==""?this.AllNodes[i].className=ClassName1:"";
this.AllNodes[i].innerHTML=(this.AllNodes[i].className==ClassName2?this.ImgBlankB:this.ImgBlankA)+this.AllNodes[i].innerHTML;
}
}
this.SetNodes = function (n) {
var sClsName=n==0?this.ClassName0:this.ClassName1;
for (i=0;i<this.AllNodes.length;i++ ) {
this.AllNodes[i].className==this.ClassName2?"":this.AllNodes[i].className=sClsName;
}
}
}
var MyCNLTreeMenu1=new CNLTreeMenu("CNLTreeMenu1","li");
MyCNLTreeMenu1.InitCss("Opened","Closed","Child","http://www.zzsky.cn/effect/files/treemenu/s.gif");
var MyCNLTreeMenu2=new CNLTreeMenu("CNLTreeMenu2","li");
MyCNLTreeMenu2.InitCss("Opened","Closed","Child","http://www.zzsky.cn/effect/files/treemenu/s.gif");
var MyCNLTreeMenu3=new CNLTreeMenu("CNLTreeMenu3","li");
MyCNLTreeMenu3.InitCss("Opened","Closed","Child","http://www.zzsky.cn/effect/files/treemenu/s.gif");
-->
</script>
</body>
</html>
問題未解決?付費(fèi)解決問題加Q或微信 2589053300 (即Q號又微信號)右上方掃一掃可加博主微信
所寫所說,是心之所感,思之所悟,行之所得;文當(dāng)無敷衍,落筆求簡潔。 以所舍,求所獲;有所依,方所成!