基于JS的树形导航的实现

网上找了个JS的树形导航,先要下载那个js包,然后放在项目中,才可以使用,做了一个小例子,留着备用。

 

页面文件要放在那个js包共同的上级文件夹中,否则会找不到图片。

 

示例代码:

前台:

 

后台返回一个JSON JS遍历读取数据

 

关于那个JSTree,简介如下:

 

对于 tree.add(id,pid,name,url,title,target,icon,iconOpen,open); 方法中的参数这里有必要说一下

Parameters
 Name Type Description
 id Number Unique identity number.
 pid NumberNumber refering to the parent node. The value for the root node has to   be -1.
 name String Text label for the node.
 url String Url for the node.
 title String Title for the node.
 target String Target for the node.
 icon String Image file to use as the icon. Uses default if not specified.
 iconOpen String Image file to use as the open icon. Uses default if not specified
 open Boolean Is the node open.

Example
mytree.add(1, 0, 'My node', 'node.html', 'node title', 'mainframe', 'img/musicfolder.gif');


上面是引自 dtree api 中的描述
下面是翻译后的描述:

id :节点自身的id
pid :节点的父节点的id
name :节点显示在页面上的名称
url :节点的链接地址
title :鼠标放在节点上所出现的提示信息
target :节点链接所打开的目标frame(如框架目标mainFrame或是_blank,_self之类)
icon :节点关闭时的显示图片的路径
iconOpen:节点打开时的显示图片的路径

open

:布尔型,节点是否打开(默认为false)


参考网站: 
http://blog.sina.com.cn/s/blog_59d6717c0100ekm3.html
http://destroydrop.com/javascripts/tree/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值