2015-06-20 28 views
-2

這裏開設一家分支jstree是html代碼:如何在JavaScript

<div id="jstree-beanDescCategorie" class="jstreeDiv" style="display: none;"> 

<div class="containerjsTree jstree jstree-2 jstree-default jstree-checkbox-selection" role="tree" aria-multiselectable="true" tabindex="0" aria-activedescendant="3" aria-busy="false"> 

<ul class="jstree-container-ul jstree-children jstree-wholerow-ul jstree-no-dots" role="group"> 

    <li id="2" class="jstree-node jstree-closed" role="treeitem" aria-selected="false" aria-level="1" aria-labelledby="2_anchor" aria-expanded="false"> 

    <div class="jstree-wholerow" unselectable="on" role="presentation"></div> 
    <i class="jstree-icon jstree-ocl" role="presentation"></i> 
    <a id="2_anchor" class="jstree-anchor" href="#" tabindex="-1"></a> 

    </li> 

當分支是開放類變爲「jstree節點jstree開」

我使用Tchromium嵌入式德爾福 我試過:

var x = document.getElementsByClassName("jstree-node jstree-closed"); 
x[1].click(); 

什麼都沒有發生,但X不爲空

回答

0

你不應該改變類,但獲得一個實例,並在其上調用open_node

// I assume "2" is the node ID as seen above 
// replace tree-container-here with your ID (the one you used to create the tree) 
window.jQuery('#tree-container-id-here').jstree(true).open_node('2'); 
+0

THKS您的回覆,我已經試過: 變種S:串; (「#jstree-beanDescCategoryie」)。jstree(true).open_node(「2」);'; javax.sourceforge.net(s); Javaexec(s); 結束; 但它不起作用 – bbd

+0

$(「#jstree-beanDescCategorie」)。jstree(「open_node」,$(「#2」));不起作用 – bbd

+0

我加載(沒有創建它)一個HTML文檔,我希望執行javascript命令以便在jstree中選擇選項。 – bbd