0

层次树:

  mouse (depth:0, sequence:0)
    *   organ system (depth:1, sequence:1)
        o   visceral organ (depth:2, sequence:2)
              urinary system (depth:3, sequence:3)
              mesentery (depth:4, sequence:4)
                  *   rest of mesentery (depth:5, sequence:5)
                  *   urogenital mesentery (depth:5, sequence:6)
              metanephros (depth:4, sequence:7)
                  *   renal capsule (depth:5, sequence:8)
                  *   nephrogenic zone (depth:5, sequence:9)

我有以下代码,它应该检索所选节点之后的第一个下一个节点的名称,该节点与所选节点具有相同的深度,并且序列值应该大于 selected_node_sequence :

/** node id has the same value as node_depth **/

  var selected_node_depth = parseInt($j(element).attr('APO_DEPTH'));
  var selected_node_sequence = parseInt($j(element).attr('APO_SEQUENCE'));

  var first_next_node_with_same_depth = $j("#"+selected_node_depth).next().attr("name"); [where first_next_node_with_same_depth sequence value > selected_node_sequence]

例如,如果 'selected_node' = 肠系膜,则 'first_next_node_with_same_depth' 应该是后肾

任何关于如何做到这一点的建议都非常感谢

4

1 回答 1

0

用纯JS获取下一个节点的简单方法:

(yournode).nextElementSibling

显然,您可以使用 getElementById 语句来获取节点,或者如果您已将节点存储在代码中的其他位置,则可以使用节点本身。如果您需要/提供更多信息,我们很乐意完善此答案。

于 2013-02-06T15:11:39.900 回答