2015-06-20 38 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