BootStrap TreeView使用實(shí)例詳解
本文實(shí)例為大家分享了BootStrap TreeView使用代碼,供大家參考,具體內(nèi)容如下
<html>
<head>
<title></title>
<link href="/Scripts/bootstrap/css/bootstrap.css" rel="stylesheet">
<link href="/Scripts/bootstrap/css/bootstrap-treeview.css" rel="stylesheet">
<script src="/Scripts/bootstrap/js/jquery.js" type="text/javascript"></script>
<script src="/Scripts/bootstrap/js/bootstrap-treeview.js" type="text/javascript"></script>
</head>
<body>
<div id="tree"></div>
<input type="button" id="btn" value="查詢" />
<script type="text/javascript">
$(function () {
function getTree() {
// Some logic to retrieve, or generate tree structure
var data = [{
text: "p1",
nodes: [{ text: "p1-1", id: '00001', nodeId: '00001' }, { text: "p1-2", id: '00002' }, { text: "p1-3", id: '00003' }, { text: "p1-4", id: '00004', nodes: [{ text: 'p1-1-1', id: '00005'}]}]
}]
return data;
}
var obj = {};
obj.text = "123";
$('#tree').treeview({
data: getTree(), // data is not optional
levels: 5,
multiSelect: true
});
$("#btn").click(function (e) {
var arr = $('#tree').treeview('getSelected');
alert(JSON.stringify(arr));
for (var key in arr) {
alert(arr[key].id);
}
})
})
</script>
</body>
</html>
彈窗口+樹形菜單的具體代碼
<html>
<head>
<title></title>
<link href="/Scripts/bootstrap/css/bootstrap.css" rel="stylesheet">
<link href="/Scripts/bootstrap/css/bootstrap-treeview.css" rel="stylesheet">
<script src="/Scripts/bootstrap/js/jquery.js" type="text/javascript"></script>
<script src="/Scripts/bootstrap/js/bootstrap.js" type="text/javascript"></script>
<script src="/Scripts/bootstrap/js/bootstrap-treeview.js" type="text/javascript"></script>
</head>
<body>
<p id="c"></p>
<!-- 按鈕觸發(fā)模態(tài)框 -->
<button class="btn btn-primary btn-lg" data-toggle="modal"
data-target="#myModal">
開始演示模態(tài)框
</button>
<!-- 模態(tài)框(Modal) -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close"
data-dismiss="modal" aria-hidden="true">
×
</button>
<h4 class="modal-title" id="myModalLabel">
模態(tài)框(Modal)標(biāo)題
</h4>
</div>
<div class="modal-body">
<div id="tree"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">關(guān)閉
</button>
<button type="button" class="btn btn-primary" id="btn">
提交更改
</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal -->
</div>
<script type="text/javascript">
$(function () {
function getTree() {
// Some logic to retrieve, or generate tree structure
var data = [{
text: "p1",
nodes: [{ text: "p1-1", id: '00001', nodeId: '00001' }, { text: "p1-2", id: '00002' }, { text: "p1-3", id: '00003' }, { text: "p1-4", id: '00004', nodes: [{ text: 'p1-1-1', id: '00005'}]}]
}]
return data;
}
var obj = {};
obj.text = "123";
$('#tree').treeview({
data: getTree(), // data is not optional
levels: 5,
multiSelect: true
});
$("#btn").click(function (e) {
var arr = $('#tree').treeview('getSelected');
for (var key in arr) {
c.innerHTML = c.innerHTML + "," + arr[key].id;
}
})
})
</script>
</body>
</html>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- bootstrap treeview 擴(kuò)展addNode方法動(dòng)態(tài)添加子節(jié)點(diǎn)的方法
- bootstrap插件treeview實(shí)現(xiàn)全選父節(jié)點(diǎn)下所有子節(jié)點(diǎn)和反選功能
- JS樹形菜單組件Bootstrap TreeView使用方法詳解
- 淺析使用BootStrap TreeView插件實(shí)現(xiàn)靈活配置快遞模板
- Bootstrap樹形菜單插件TreeView.js使用方法詳解
- 淺析BootStrap Treeview的簡(jiǎn)單使用
- 基于MVC5和Bootstrap的jQuery TreeView樹形控件(二)之?dāng)?shù)據(jù)支持json字符串、list集合
- 基于MVC5和Bootstrap的jQuery TreeView樹形控件(一)之?dāng)?shù)據(jù)支持json字符串、list集合
- bootstrap-treeview自定義雙擊事件實(shí)現(xiàn)方法
- bootstrap-Treeview實(shí)現(xiàn)級(jí)聯(lián)勾選
相關(guān)文章
微信小程序用swiper實(shí)現(xiàn)滑動(dòng)刻度尺
這篇文章主要為大家詳細(xì)介紹了微信小程序用swiper實(shí)現(xiàn)滑動(dòng)刻度尺,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-06-06
JavaScript中return返回多個(gè)值的三個(gè)方法實(shí)現(xiàn)
本文主要介紹了JavaScript中return返回多個(gè)值的三個(gè)方法實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-08-08
js流動(dòng)式效果顯示當(dāng)前系統(tǒng)時(shí)間
這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)流動(dòng)式時(shí)間效果的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-05-05
模仿JQuery.extend函數(shù)擴(kuò)展自己對(duì)象的js代碼
最近打算寫個(gè)自己的js工具集合,把自己平常經(jīng)常使用的方法很好的封裝起來(lái),其中模仿了jq的結(jié)構(gòu)。2009-12-12
基于jQuery+PHP+Mysql實(shí)現(xiàn)在線拍照和在線瀏覽照片
本文通過php jquery和mysql三者相結(jié)合,實(shí)現(xiàn)web版在線拍照上傳并可在線瀏覽,下面給大家分享基于jQuery+PHP+Mysql實(shí)現(xiàn)在線拍照和在線瀏覽照片,需要的朋友可以參考下2015-09-09
JS+CSS實(shí)現(xiàn)一個(gè)氣泡提示框
氣泡提示框牽扯到的技術(shù)有:JS響應(yīng)鼠標(biāo)的事件、純CSS制作三角形,附截圖及示例代碼,感興趣的朋友可以參考下2013-08-08
利用JS如何計(jì)算字符串所占字節(jié)數(shù)示例代碼
因?yàn)樽罱?xiàng)目有個(gè)需求要用js計(jì)算一串字符串寫入到localStorage里所占的內(nèi)存,所以便有了這篇文章,下面這篇文章主要給大家介紹了關(guān)于利用JS如何計(jì)算字符串所占字節(jié)數(shù)的相關(guān)資料,需要的朋友可以參考下。2017-09-09

