目前做了一个easyui项目需要显示多级菜单,菜单配置到数据库中,因此每级菜单都需要到数据库中取,用了jQuery EasyUI方便多了。

效果体验:http://hovertree.com/texiao/jeasyui/2/

下载:http://hovertree.com/h/bjaf/kbtdmn5u.htm

参考:http://hovertree.com/jeasyui/demo/tree/checkbox.html

http://hovertree.com/jeasyui/demo/tree/dnd.html

HTML代码:

 <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>树菜单操作 - jQuery EasyUI 范例 - 何问起</title><base target="_blank" />
<link rel="stylesheet" type="text/css" href="http://hovertree.com/jeasyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="http://hovertree.com/jeasyui/themes/icon.css">
<link rel="stylesheet" type="text/css" href="http://hovertree.com/jeasyui/demo/demo.css">
<script type="text/javascript" src="http://hovertree.com/ziyuan/jquery/jquery-1.12.0.min.js"></script>
<script type="text/javascript" src="http://hovertree.com/jeasyui/jquery.easyui.min.js"></script>
<style>a{color:black;text-decoration:none;}</style>
</head>
<body>
<h2>树菜单操作</h2>
<p>点击下列按钮体验效果.</p>
<div style="margin:20px 0;">
<a href="javascript:;" class="easyui-linkbutton" onclick="collapseAll()" target="_self">全部收起</a>
<a href="javascript:;" class="easyui-linkbutton" onclick="expandAll()" target="_self">全部展开</a>
<a href="javascript:;" class="easyui-linkbutton" onclick="expandTo()" target="_self">展开选择指定项</a>
<a href="javascript:;" class="easyui-linkbutton" onclick="getSelected()" target="_self">获取选择项值</a>
</div>
<div class="easyui-panel" style="padding:5px">
<ul id="tt" class="easyui-tree" data-options="url:'tree_data1.json',method:'get',animate:true"></ul>
</div>
<br /><br />
<a href="http://hovertree.com/">首页</a>
<script type="text/javascript">
function collapseAll(){
$('#tt').tree('collapseAll');
}
function expandAll(){
$('#tt').tree('expandAll');
}
function expandTo(){
var node = $('#tt').tree('find',113);
$('#tt').tree('expandTo', node.target).tree('select', node.target);
}
function getSelected(){
var node = $('#tt').tree('getSelected');
if (node){
var s = node.text;
if (node.attributes){
s += ","+node.attributes.p1+","+node.attributes.p2;
}
alert(s);
}
}
</script>
</body>
</html>

菜单项的json文件代码:

[
{
"id": 1,
"text": "Tree菜单",
"children": [
{
"id": 11,
"text": "Photos",
"state": "closed",
"children": [
{
"id": 111,
"text": "<a href='http://hovertree.com'>何问起</a>"
},
{
"id": 112,
"text": "<a href='http://hovertree.com/jeasyui/'>EasyUI</a>"
},
{
"id": 113,
"text": "<a href='http://hovertree.com/menu/jquery/'>jQuery</a>"
}
]
},
{
"id": 12,
"text": "Program Files",
"children": [
{
"id": 121,
"text": "<a href='http://hovertree.com/h/bjaf/hoverclock.htm'>HoverClock</a>"
},
{
"id": 122,
"text": "<a href='http://hovertree.com/h/bjaf/easysector.htm'>画饼图</a>",
"attributes": {
"p1": "Custom Attribute1",
"p2": "Custom Attribute2"
}
},
{
"id": 123,
"text": "<a href='http://hovertree.com/h/bjaf/hovertreebatch.htm'>批量重命名</a>"
},
{
"id": 124,
"text": "<a href='http://tool.hovertree.com/a/base64/'>图像转码</a>",
"checked": true
}
]
},
{
"id": 13,
"text": "<a href='http://hovertree.com/texiao/game/'>见缝插针</a>"
},
{
"id": 14,
"text": "<a href='http://hovertree.com/shortanswer/bjaf/j43wyyvr.htm'>选择题</a>"
},
{
"id": 15,
"text": "<a href='http://hovertree.com/h/bjaf/css3icon.htm'>图标</a>"
},
{
"id": 16,
"text": "<a href='http://hovertree.com/h/bjaf/treeaction.htm'>原文</a>"
}
]
}
]

更多特效:http://www.cnblogs.com/roucheng/p/texiao.html

最新文章

  1. 2_MVC+EF+Autofac(dbfirst)轻型项目框架_用户权限验证
  2. iOS开发知识点总结
  3. Codeforces Round #341 Div.2 D. Rat Kwesh and Cheese
  4. 51nod 1006 最长公共子序列Lcs(经典动态规划)
  5. Hadoop系列之(一):Hadoop单机部署
  6. iOS - ASIHTTPRequest 网络请求
  7. 20.allegro.铺铜[原创]
  8. 代码片段 - Golang 实现简单的 Web 服务器
  9. nyoj-291 互素数个数 欧拉函数
  10. cinder /etc/lvm/lvm.conf 注意点
  11. linux小白成长之路8————访问Docker中的mysql
  12. 分布式存储ceph理论
  13. 查看局域网中连接的主机名和对应的IP地址
  14. 20165206 2017-2018-2 《Java程序设计》第二周学习总结
  15. 廖雪峰Java6 IO编程-2input和output-6classpath资源
  16. Windows server 2008 R2 安装指引
  17. JIRA状态为任务结束,但是解决结果为未解决相关配置
  18. 笔记--Wcf全面解析(上)---(1)
  19. swift -- 如何在swift下,使用类似oc的pch文件功能
  20. 崩溃block

热门文章

  1. ABP理论学习之工作单元(Unit of Work)
  2. DRY(Don&#39;t Repeat Yourself )原则
  3. ubuntu下rhythmbox歌名显示乱码问题解决
  4. WCF 的 Service Instance模式和并发处理
  5. [公告]Senparc.Weixin v4.7.0 升级说明(2016-08-08)
  6. ora-01652无法通过128(在表空间temp中)扩展temp段
  7. MongoDB 维护Replica Set
  8. Java之控制反转和依赖注入
  9. 【原创】开源Math.NET基础数学类库使用(10)C#进行基本数据统计
  10. 【经验之谈】Git使用之Windows环境下配置