2013-02-06 49 views
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' 應該是後腎

關於如何做到這一點的任何建議是最讚賞

回答

0

簡單的方式來獲得與純JS的下一個節點:

(yournode).nextElementSibling 

顯然,你可以使用一個的getElementById語句獲取節點,或節點本身如果你已經在你的代碼中存儲了其他地方。如果您需要/提供更多信息,將很樂意完善此答案。

+0

這是否回答了您的問題? –