日期:2014-05-19  浏览次数:20430 次

各位大侠小弟高分求一代码!分数不够可以再加!
求用javascript   与DIV实现的三层或以上的树型目录

------解决方案--------------------
/*****************************
JavaScript Code for CNLTreeMenu
Version: Ver 1.02
Author : CNLei, 枫岩
E-Mail : CNLei.Y.L@gmail.com
MySite : http://www.cnlei.net
Passed : XHtml 1.0, CSS 2.0, IE5.0+, FF1.0+, Opera8.5+
Update : 2006-2-12
*****************************/
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 || "css/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;
}
}
}


------解决方案--------------------
<!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 " lang= "zh-cn ">
<head>
<title> CNL Tree Menu Ver1.02 - 无限级树形菜单 Written by CNLei, 枫岩 </title>
<meta http-equiv= "content-type " content= "text/html;charset=gb2312 " />
<meta name= "generator " content= "editplus " />
<meta name= "author " content= "CNLei,枫岩,www.cnlei.net " />
<meta name= "keywords " content= "CSS Menu,树形菜单,CNLei " />
<meta name= "description " content= " " />
<!--
**************************************
HTML Code for CNLTreeMenu
Version: Ver 1.02
Author : CNLei, 枫岩
E-Mail : CNLei.Y.L@gmail.com
MySite : http://www.cnlei.net
Passed : XHtml 1.0, CSS 2.0, IE5.0+, FF1.0+, Opera8.5+
Update : 2006-2-12
**************************************
-->
<link type= "text/css " rel= "stylesheet " href= "css/css4cnltreemenu.css " />
<script type= "text/javascript " src= "js/js4cnltreemenu.js "> </script>
</head>
<body>
<p> 实例演示: </p>
<dl>
<dt> CNL Tree Menu &