showing results for - "js tree example"
Gabriel
21 Aug 2017
1
2<!DOCTYPE html>
3<html>
4<head>
5  <meta charset="utf-8">
6  <title>jsTree test</title>
7  <!-- 2 load the theme CSS file -->
8  <link rel="stylesheet" href="dist/themes/default/style.min.css" />
9</head>
10<body>
11  <!-- 3 setup a container element -->
12  <div id="jstree">
13    <!-- in this example the tree is populated from inline HTML -->
14    <ul>
15      <li>Root node 1
16        <ul>
17          <li id="child_node_1">Child node 1</li>
18          <li>Child node 2</li>
19        </ul>
20      </li>
21      <li>Root node 2</li>
22    </ul>
23  </div>
24  <button>demo button</button>
25
26  <!-- 4 include the jQuery library -->
27  <script src="dist/libs/jquery.js"></script>
28  <!-- 5 include the minified jstree source -->
29  <script src="dist/jstree.min.js"></script>
30  <script>
31  $(function () {
32    // 6 create an instance when the DOM is ready
33    $('#jstree').jstree();
34    // 7 bind to events triggered on the tree
35    $('#jstree').on("changed.jstree", function (e, data) {
36      console.log(data.selected);
37    });
38    // 8 interact with the tree - either way is OK
39    $('button').on('click', function () {
40      $('#jstree').jstree(true).select_node('child_node_1');
41      $('#jstree').jstree('select_node', 'child_node_1');
42      $.jstree.reference('#jstree').select_node('child_node_1');
43    });
44  });
45  </script>
46</body>
47</html>
48 
queries leading to this page
create js treejavascript create tree objectis this a tree 3f javascripttree javascript examplehow to make tree structure in javascripttree implementation in jshow to create tree structure in javascripttree node javascriptcreate a tree in jsjavascript programming tree termhow to create a tree in javascriptstructure tree javascripttree javascript implementationcreate tree wit nodes javascriptexample of tree javascriptimplementation of tree in jswhat is tree jscreate tree of data javascripttree in jsjavascript tree codejavascript tree data structurejavascript tree nodecreate tree data structure javascripttree javascriptcreate tree in javascripttree list javascriptbuild tree in javascripttree js tutorialjs tree structurejs treejavascript syntax treejavasctipt treetree structure jsjavascript tree structure arrayjs tree demoexample js treewhen is a tree data structure use in jvascriptjavascript treejavascript code tree structure for functionstree with javascriptjavascript code tree structurewriting a tree javscriptimplementing a tree in javascriptcreate tree structure in javascript from arrayjavascript dhtml treejavascript tree structurejavascript tree algorithmhow to make tree in jsimplement tree in javascriptwhat 27s structure tree javascriptbuilding a tree in jshow to make a tree in jshow to create a tree in jstree set in jstree implementation in javascripttree code in javascripttree in javascriptdata structure tree in javascript codejavascript tree data structure exampletree jshow to make tree in javascriptjs tree examplenode tree javascriptjs tree example