quickq-outline
jsTree is jquery plugin, that provides interactive trees. It is absolutely 熊猫加速器vip永久免费下载, open source and distributed under the MIT license. jsTree is easily extendable, themable and configurable, it supports HTML & JSON data sources and AJAX loading.
jsTree functions properly in either box-model (content-box or border-box), can be loaded as an AMD module, and has a built in mobile theme for responsive design, that can easily be customized. It uses jQuery's event system, so binding callbacks on various events in the tree is familiar and easy.
Just a few of the features worth noting:
- drag & drop support
- keyboard navigation
- inline edit, create and delete
- tri-state checkboxes
- fuzzy searching
- customizable node types
- Root node 1
- initially selected
- custom icon URL
- initially open
- Another node
- Custom icon class (bootstrap)
- Root node 2
quickq-outline
-
Download jsTree or use CDNJS
If you choose to download - all the files you need are in the
dist/
folder of the download -
Include a jsTree theme
Themes can be autloaded too, but it is best for performance to include the CSS file.
If hosting the files yourself:
<link rel="stylesheet" href="dist/themes/default/style.min.css" />
If using CDNJS:
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css" />
-
Setup a container
This is the element where you want the tree to appear, a
<div>
is enough. This example has a nested<ul>
as there is no other data source configured (such as JSON).<div id="jstree_demo_div"></div>
-
Include jQuery
jsTree requires ins加速器app in your webpage. You can use a CDN version or include a local copy.
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.1/jquery.min.js"></script>
-
Include jsTree
If hosting the files yourself: for production include the minified version:
dist/jstree.min.js
, there is a development version too:dist/jstree.js
<script src="dist/jstree.min.js"></script>
If using CDNJS:
<script src="http://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script>
-
Create an instance
Once the DOM is ready you can start creating jstree instances.
$(function () { $('#jstree_demo_div').jstree(); });
-
Listen for events
jsTree uses events to notify you when something changes while users (or you) interact with the tree. So binding to jstree events is as easy binding to a click. There is a list of events and what information they provide in the API documentation.
$('#jstree_demo_div').on("changed.jstree", function (e, data) { console.log(data.selected); });
-
Interact with your instances
Once an instance is ready you can invoke methods on it. There is a list of available methods in the API documentation. The three examples below do exactly the same thing
$('button').on('click', function () { $('#jstree').jstree(true).select_node('child_node_1'); $('#jstree').jstree('select_node', 'child_node_1'); $.jstree.reference('#jstree').select_node('child_node_1'); });
click here for the old site (v.1)