JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.1.0/jstree.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.1.0/themes/default/style.min.css">
<div id="jstree"></div>
CSS
.jstree-contextmenubtn { position:relative; cursor:pointer; }
JavaScript
// additional icon on node (outside of anchor)
(function ($, undefined) {
"use strict";
var img = document.createElement('IMG');
img.src = "http://jstree.com/tree-icon.png";
img.className = "jstree-contextmenubtn";
$.jstree.plugins.contextmenubtn = function (options, parent) {
this.bind = function () {
parent.bind.call(this);
this.element
.on("click.jstree", ".jstree-contextmenubtn", $.proxy(function (e) {
e.stopImmediatePropagation();
$(e.target).closest('.jstree-node').children('.jstree-anchor').trigger('contextmenu');
}, this));
};
this.teardown = function () {
this.element.find(".jstree-contextmenubtn").remove();
parent.teardown.call(this);
};
this.redraw_node = function(obj, deep, callback, force_draw) {
obj = parent.redraw_node.call(this, obj, deep, callback, force_draw);
if(obj) {
var tmp = img.cloneNode(true);
obj.insertBefore(tmp, obj.childNodes[2]);
}
return obj;
};
};
})(jQuery);
$('#jstree').jstree({
core : {
check_callback : true,
data : [
{ "id" : "1", "parent" : "#", "text" : "root" },
{ "id" : "2", "parent" : "1", "text" : "child 1" },
{ "id" : "3", "parent" : "1", "text" : "child 2" }
],
},
plugins : ["wholerow","contextmenu","contextmenubtn"]
}).on("ready.jstree", function (e, data) {
data.instance.open_all();
});