Parent node check in jstree

笑着哭i 提交于 2019-12-06 16:56:58

You can use this code:

$('#FolderTree').on("select_node.jstree", function (e, data) {
    var checkedValue = data.node.text;
    var isParent = data.instance.is_parent(); 
    // you can also use is_leaf() to check the opposite
});

is_parent will tell you if the node has any children, is_leaf will tell you if it is a leaf node (if it has no children) - use one or the other.

If you need to check if a node is a root node you can use:
var isRoot = (data.node.parents.length === 1)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!