Home  >  Article  >  Web Front-end  >  Ztree method to obtain the child node id collection of the currently selected node_javascript skills

Ztree method to obtain the child node id collection of the currently selected node_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:14:241354browse

The example in this article describes how ztree obtains the set of child node ids of the currently selected node. Share it with everyone for your reference. The specific analysis is as follows:

Requirements: Get the set of child node ids of the currently selected node.

Steps:

1. Get the current node

2. Use the ztree method transformToArray() to obtain the collection of child node objects of the currently selected node (including the selected node).

3. Traverse the collection and retrieve the required values.

treeNode: 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 design.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn