网页树形折叠菜单制作

网页树形折叠菜单制作,第1张

JavaScript Code: function Ob(o){ var o=documentgetElementById(o)documentgetElementById(o):o; return o; } function Hd(o) { Ob(o)styledisplay="none"; } function Sw(o) { Ob(o)styledisplay=""; } function ExCls(o,a,b,n){ var o=Ob(o); for(i=0;i<n;i++) {o=oparentNode;} oclassName=oclassName==ab:a; } function CNLTreeMenu(id,TagName0) { thisid=id; thisTagName0=TagName0=="""li":TagName0; thisAllNodes = Ob(thisid)getElementsByTagName(TagName0); thisInitCss = function (ClassName0,ClassName1,ClassName2,ImgUrl) { thisClassName0=ClassName0; thisClassName1=ClassName1; thisClassName2=ClassName2; thisImgUrl=ImgUrl || "css/sgif"; thisImgBlankA ="<img src=\"css/sgif\" class=\"s\" onclick=\"ExCls(this,'"+ClassName0+"','"+ClassName1+"',1);\" alt=\"展开/折叠\" />"; thisImgBlankB ="<img src=\"css/sgif\" class=\"s\" />"; for (i=0;i<thisAllNodeslength;i++ ) { thisAllNodes[i]className==""thisAllNodes[i]className=ClassName1:""; thisAllNodes[i]innerHTML=(thisAllNodes[i]className==ClassName2thisImgBlankB:thisImgBlankA)+thisAllNodes[i]innerHTML; } } thisSetNodes = function (n) { var sClsName=n==0thisClassName0:thisClassName1; for (i=0;i<thisAllNodeslength;i++ ) { thisAllNodes[i]className==thisClassName2"":thisAllNodes[i]className=sClsName; } } } CSS Code: CNLTreeMenu imgs {cursor:pointer;vertical-align:middle;} CNLTreeMenu ul {padding:0;} CNLTreeMenu li {list-style:none;padding:0;} Closed ul {display:none;} Child imgs {background:none;cursor:default;} #CNLTreeMenu1 ul {margin:0 0 0 17px;} #CNLTreeMenu1 imgs {width:20px;height:15px;} #CNLTreeMenu1 Opened imgs {background:url(skin1/openedgif) no-repeat 0 0;} #CNLTreeMenu1 Closed imgs {background:url(skin1/closedgif) no-repeat 0 0;} #CNLTreeMenu1 Child imgs {background:url(skin1/childgif) no-repeat 3px 5px;} #CNLTreeMenu2 ul {margin:0 0 0 17px;} #CNLTreeMenu2 imgs {width:17px;height:15px;} #CNLTreeMenu2 Opened imgs {background:url(skin2/openedgif) no-repeat 4px 6px;} #CNLTreeMenu2 Closed imgs {background:url(skin2/closedgif) no-repeat 3px 6px;} #CNLTreeMenu2 Child imgs {background:url(skin2/childgif) no-repeat 3px 5px;} #CNLTreeMenu3 ul {margin:0 0 0 17px;} #CNLTreeMenu3 imgs {width:34px;height:18px;} #CNLTreeMenu3 Opened imgs {background:url(skin3/openedgif) no-repeat 0 1px;} #CNLTreeMenu3 Closed imgs {background:url(skin3/closedgif) no-repeat 0 1px;} #CNLTreeMenu3 Child imgs {background:url(skin3/childgif) no-repeat 13px 2px;} html code: <p> <!--CNLTreeMenu Start:--> </p> <div class="CNLTreeMenu" id="CNLTreeMenu1"> <h4>CNL Tree Menu1</h4> <p><a id="AllOpen_1" href="#" onclick="MyCNLTreeMenu1SetNodes(0);Hd(this);Sw('AllClose_1');">全部展开</a><a id="AllClose_1" href="#" onclick="MyCNLTreeMenu1SetNodes(1);Hd(this);Sw('AllOpen_1');" style="display:none;">全部折叠</a></p> <ul> <li class="Opened"><a href=" >

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zz/10658670.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-10
下一篇 2023-05-10

发表评论

登录后才能评论

评论列表(0条)

保存