If you need to change the icon of each selected node, Adnan Y's answer will work (just make sure data.action is "select_node" ):
$("#jstree2").on('changed.jstree', function(evt, data) { if(data.action === "select_node") { data.instance.set_icon(data.node, 'http://jstree.com/tree-icon.png'); } });
If you need to respond to opening and closing nodes, use a similar code:
$("#jstree2") .on('open_node.jstree', function(evt, data) { data.instance.set_icon(data.node, 'http://jstree.com/tree-icon.png'); }) .on('close_node.jstree', function(evt, data) { data.instance.set_icon(data.node, true); });
In the second example, the icon is true - this will restore it to the default icon (if that is what you need).
source share