This article example describes the method of ztree obtaining the currently selected node child node id collection. Share it for your reference. The specific analysis is as follows:
Requirement: Get the collection of child node ids of the currently selected node.
step:
1. Get the current node
2. Use ztree's method transformToArray() to obtain the collection of child node objects of the currently selected node (including selected nodes).
3. Iterate through the collection and take out the required value.
treeNode: The currently selected node object
function getChildNodes(treeNode) { var childNodes = ztree.transformToArray(treeNode); var nodes = new Array(); for(i = 0; i < childNodes.length; i++) { nodes[i] = childNodes[i].id; } return nodes.join(",");}I hope this article will be helpful to everyone's JavaScript programming.