Javascript+dom Tree Menu class, hope Friends to progress _javascript skills
Source: Internet
Author: User
More than the tree menu JS Online is that they wrote a tree menu category, since that is not bad, open everyone to share and explore, and everyone to progress the most happy!!
/* Kuomart.com__mykuomart, Create by Ybcola (at) 163.com, 2006-7-2
Last Modified 2006-7-2, ybcola@163.com *
<!--
function Dtree () {
This. Menugroupclose= "Images/treeview_close.gif"; Menu Close icon
This. Menugroupopen= "Images/treeview_open.gif"; Menu Open icon
This. Menuitemclass= ""; menu item Style
This. Menuiteminfoclass= ""; Menu link Style
This. Menuitemlpad= "12px";//Sub Menu indent kernel value
This. Defaultgroupstate=false; Default state when menu is assembled
document.write ("<div id=\" treeroot\ "></div>");
This. Node=document.getelementbyid ("Treeroot");
0 node dom to image, array 1 for the connection display, 2 for connection href,3 for connection target,4 for connection display front icon
This. Additem=function (Menuinfo) {
var div=creatediv ();
var div1=creatediv ();
var ico=[this. Menugroupclose,this. Menugroupopen];
Div.classname=this. Menuitemclass;
Div1.style.marginleft=this. Menuitemlpad;
Div1.style.display=this. Defaultgroupstate "": "None";
var node=menuinfo[0]?menuinfo[0][1]:this. Node;
var iteminfo= "";
if (menuinfo[4]) iteminfo= "if (menuinfo[2]) iteminfo+= "<a href=\" "+menuinfo[2]+" \ "target=\" "+menuinfo[3]+" \ "class=\" "+this". Menuiteminfoclass+ ">";
ITEMINFO+=MENUINFO[1];
if (menuinfo[2]) iteminfo+= "</a>";
Div.innerhtml=iteminfo;
Node.appendchild (DIV);
Node.appendchild (DIV1);
if (Menuinfo[0]) {
if (!menuinfo[0][0].havechild) {
var as=document.createelement ("img");
AS.SRC=ICO[1];
As.align= "Absmiddle";
As.onclick=function () {
Swapshow (Node,as,ico);
}
Menuinfo[0][0].insertbefore (As,menuinfo[0][0].firstchild);
As.insertadjacenttext ("Afterend", "");
Menuinfo[0][0].havechild=true;
}
}
return [DIV,DIV1];
}
function Creatediv () {
var div=document.createelement ("div");
return div;
}
function Swapshow (obj,ico,oo) {
if (obj.style.display!= "") {
Obj.style.display= "";
ICO.SRC=OO[0];
}
else{
Obj.style.display= "None";
ICO.SRC=OO[1];
}
}
}
-->
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service