jQuery插件zTree實現(xiàn)的多選樹效果示例
本文實例講述了jQuery插件zTree實現(xiàn)的多選樹效果。分享給大家供大家參考,具體如下:
1、實現(xiàn)代碼:
<!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:"黃石港區(qū)"},
{ id:122, pId:12, name:"西塞山區(qū)"},
{ id:2, pId:0, name:"湖南省", open:true},
{ id:21, pId:2, name:"長沙市"},
{ id:22, pId:2, name:"株洲市", open:true},
{ id:221, pId:22, name:"天元區(qū)"},
{ id:222, pId:22, name:"荷塘區(qū)"},
{ 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、實現(xiàn)效果圖:

3、源碼說明
(1)Y、N、"p"和“s”說明
Y 屬性定義 checkbox 被勾選后的情況;
N 屬性定義 checkbox 取消勾選后的情況;
"p" 表示操作會影響父級節(jié)點;
"s" 表示操作會影響子級節(jié)點。
(2)chkboxType: { "Y": "s", "N": "ps" }
表示checkbox勾選操作,只影響子節(jié)點;取消勾選操作,影響父子節(jié)點
附:zTree_v3插件點擊此處本站下載。
更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery常用插件及用法總結(jié)》、《jquery中Ajax用法總結(jié)》、《jQuery表格(table)操作技巧匯總》、《jQuery擴展技巧總結(jié)》、《jQuery常見經(jīng)典特效匯總》及《jquery選擇器用法總結(jié)》
希望本文所述對大家jQuery程序設(shè)計有所幫助。
相關(guān)文章
jQuery+PHP實現(xiàn)微信轉(zhuǎn)盤抽獎功能的方法
這篇文章主要介紹了jQuery+PHP實現(xiàn)微信轉(zhuǎn)盤抽獎功能的方法,詳細分析了抽獎程序界面設(shè)計、前臺jQuery交互、后臺概率算法等抽獎功能相關(guān)技巧,需要的朋友可以參考下2016-05-05
基于EasyUI的基礎(chǔ)之上實現(xiàn)樹形功能菜單
這篇文章主要介紹了基于EasyUI的基礎(chǔ)之上實現(xiàn)樹形功能菜單,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2017-06-06
jquery插件jSignature實現(xiàn)手動簽名
在IE7~IE8這種不支持HTML5的瀏覽器上,是利用Flash嵌入的方式實現(xiàn)的簽名處理,在支持的HTML5的瀏覽器上默認采用canvas標簽處理簽名,可以生成 PNG格式、SVG格式的簽名圖片。非常適合在IPAD等移動客戶端上實現(xiàn)手寫簽名的,該插件基于JQuery2015-05-05
jQuery 自動增長的文本輸入框?qū)崿F(xiàn)代碼
文本輸入框內(nèi)的字數(shù)不能確定,而input type="text"的size是固定的,當字數(shù)超過size時(默認是20),先輸入的內(nèi)容就會從文本框的左端隱藏起來,不便于輸入。2010-04-04
jQuery length 和 size()區(qū)別總結(jié)
這篇文章主要介紹了jQuery length 和 size()區(qū)別總結(jié),在這里length是屬性,size()是方法,需要的朋友可以參考下2018-04-04

