jQuery插件zTree实现的多选树效果示例
本文实例讲述了jQuery插件zTree实现的多选树效果。分享给大家供大家参考,具体如下:
1、实现代码:
<!DOCTYPE html> <html> <head> <title>多选树</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" type="text/css" href="zTree_v3/css/demo.css" rel="external nofollow" > <link rel="stylesheet" type="text/css" href="zTree_v3/css/zTreeStyle/zTreeStyle.css" rel="external nofollow" > <script type="text/javascript" src="zTree_v3/js/jquery-1.4.4.min.js"></script> <script type="text/javascript" src="zTree_v3/js/jquery.ztree.core.min.js"></script> <script type="text/javascript" src="zTree_v3/js/jquery.ztree.excheck.min.js"></script> <script type="text/javascript"> <!-- var setting = { check: { enable: true, chkStyle: "checkbox", chkboxType: { "Y": "s", "N": "ps" } }, data: { simpleData: { enable: true } } }; var zNodes =[ { id:1, pId:0, name:"湖北省", open:true}, { id:11, pId:1, name:"武汉市", open:true}, { id:111, pId:11, name:"汉口"}, { id:112, pId:11, name:"武昌"}, { id:12, pId:1, name:"黄石市", open:true}, { id:121, pId:12, name:"黄石港区"}, { id:122, pId:12, name:"西塞山区"}, { id:2, pId:0, name:"湖南省", open:true}, { id:21, pId:2, name:"长沙市"}, { id:22, pId:2, name:"株洲市", open:true}, { id:221, pId:22, name:"天元区"}, { id:222, pId:22, name:"荷塘区"}, { id:23, pId:2, name:"湘潭市"} ]; $(document).ready(function(){ $.fn.zTree.init($("#treeMultiple"), setting, zNodes); }); //--> </script> </head> <body> <div class="content_wrap" style="text-align: center;"> <div class="zTreeDemoBackground left"> <ul id="treeMultiple" class="ztree" style="height: 300px; width:150px; overflow-y: auto"></ul> </div> </div> </body> </html>
2、实现效果图:
3、源码说明
(1)Y、N、"p"和“s”说明
Y 属性定义 checkbox 被勾选后的情况;
N 属性定义 checkbox 取消勾选后的情况;
"p" 表示操作会影响父级节点;
"s" 表示操作会影响子级节点。
(2)chkboxType: { "Y": "s", "N": "ps" }
表示checkbox勾选操作,只影响子节点;取消勾选操作,影响父子节点
附:zTree_v3插件点击此处本站下载。
更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery常用插件及用法总结》、《jquery中Ajax用法总结》、《jQuery表格(table)操作技巧汇总》、《jQuery扩展技巧总结》、《jQuery常见经典特效汇总》及《jquery选择器用法总结》
希望本文所述对大家jQuery程序设计有所帮助。
相关推荐
83493467 2014-01-13
小源丶同学 2015-03-04
83443560 2018-12-05
xchrist 2016-03-03
LingPF 2019-06-30
shanhuijava 2015-12-11
火星的你 2015-07-10
88463368 2015-03-04
Chydar 2019-06-27
CrazyDogWang 2014-08-20
罗惠东 2014-03-09
asdjkl 2014-01-13
kbkiss 2019-06-26
愚盦 2013-10-21
zgwyfz 2013-09-14
momode 2013-06-28
84483368 2013-06-02