博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
无限级可刷新树型导航菜单
阅读量:7147 次
发布时间:2019-06-29

本文共 3605 字,大约阅读时间需要 12 分钟。

hot3.png

 转载直接贴代码:

无限级可刷新Js树型菜单
function Node(id, pid, name, url, title, target, icon, iconOpen, open) {this.id = id;this.pid = pid;this.name = name;this.url = url;this.title = title;this.target = target;this.icon = icon;this.iconOpen = iconOpen;this._io = open || false;this._is = false;this._ls = false;this._hc = false;this._ai = 0;this._p;};// Tree objectfunction dTree(objName) {this.config = {target: null,folderLinks: true,useSelection: true,useCookies: true,useLines: true,useIcons: true,useStatusText: false,closeSameLevel: false,inOrder: false}this.icon = {root: 'http://www.qpsh.com/icon/wx/base.gif',folder: 'http://www.qpsh.com/icon/wx/folder.gif',folderOpen: 'http://www.qpsh.com/icon/wx/folderopen.gif',node: 'http://www.qpsh.com/icon/wx/page.gif',empty: 'http://www.qpsh.com/icon/wx/empty.gif',line: 'http://www.qpsh.com/icon/wx/line.gif',join: 'http://www.qpsh.com/icon/wx/join.gif',joinBottom: 'http://www.qpsh.com/icon/wx/joinbottom.gif',plus: 'http://www.qpsh.com/icon/wx/plus.gif',plusBottom: 'http://www.qpsh.com/icon/wx/plusbottom.gif',minus: 'http://www.qpsh.com/icon/wx/minus.gif',minusBottom: 'http://www.qpsh.com/icon/wx/minusbottom.gif',nlPlus: 'http://www.qpsh.com/icon/wx/nolines_plus.gif',nlMinus: 'http://www.qpsh.com/icon/wx/nolines_minus.gif'};this.obj = objName;this.aNodes = [];this.aIndent = [];this.root = new Node(-1);this.selectedNode = null;this.selectedFound = false;this.completed = false;};// Adds a new node to the node arraydTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open) {this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open);};// Open/close all nodesdTree.prototype.openAll = function() {this.oAll(true);};dTree.prototype.closeAll = function() {this.oAll(false);};// Outputs the tree to the pagedTree.prototype.toString = function() {var str = '
\n';if (document.getElementById) {if (this.config.useCookies) this.selectedNode = this.getSelected();str += this.addNode(this.root);} else str += 'Browser not supported.';str += '';if (!this.selectedFound) this.selectedNode = null;this.completed = true;return str;};// Creates the tree structuredTree.prototype.addNode = function(pNode) {var str = '';var n=0;if (this.config.inOrder) n = pNode._ai;for (n; n
' + this.indent(node, nodeId);if (this.config.useIcons) {if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node);if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node;if (this.root.id == node.pid) {node.icon = this.icon.root;node.iconOpen = this.icon.root;}str += '
';}if (node.url) {str += '
';}else if ((!this.config.folderLinks || !node.url) && node._hc && node.pid != this.root.id)str += '
';str += node.name;if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '';str += '';if (node._hc) {str += '
';str += this.addNode(node);str += '';}this.aIndent.pop();return str;};// Adds the empty and line iconsdTree.prototype.indent = function(node, nodeId) {var str = '';if (this.root.id != node.pid) {for (var n=0; n
';(node._ls) ? this.aIndent.push(0) : this.aIndent.push(1);if (node._hc) {str += '
';} else str += '
';}return str;};// Checks if a node has any children and if it is the last siblingdTree.prototype.setCS = function(node) {var lastId;for (var n=0; n

无限级可刷新Js树型菜单

Example

展开所有 | 
收起所有

应有尽有的网页特效网址:
http://js.alixixi.com

 

转载于:https://my.oschina.net/discussjava/blog/213217

你可能感兴趣的文章
批处理中的echo命令图文详解
查看>>
Chrome 自动填充的表单是淡黄色的背景,有方法自定义
查看>>
hough变换中,直线方程从XY空间转换到参数空间的转换过程
查看>>
阿里云server该数据光盘安装操作
查看>>
Onedrive 明年初基础容量缩小到5G,执行这一步骤避免(保持30G)
查看>>
IOS中NSUserDefaults的用法(轻量级本地数据存储)
查看>>
大组合取模之:1<=n<=m<=1e6,1<=p<=1e9
查看>>
百度map android sdk3.5实现定位 并跳转的指定坐标,加入标记
查看>>
Oracle VM VirtualBox技巧
查看>>
怎样自己构建一个小型的Zoomeye----从技术细节探讨到实现
查看>>
Hadoop 2.7.1 源代码目录结构分析
查看>>
《转》 Openstack Grizzly 指定 compute node 创建 instance
查看>>
[转]PhoneGap使用PushPlugin插件实现消息推送
查看>>
PHP传值与传址(引用)
查看>>
JSP简单练习-数组应用实例
查看>>
Directx11学习笔记【四】 封装一个简单的Dx11DemoBase
查看>>
DMA(STM32)
查看>>
最简单的基于FFMPEG的音频编码器(PCM编码为AAC)
查看>>
Boost.Asio基础(三)
查看>>
【转载】学习新东西的唯一方法
查看>>