2
我正在使用jstree,如果可能,我想知道如何隱藏/顯示節點。我給列表項目一個「貓」ID來選擇他們與jQuery,但這是行不通的。jsTree顯示/隱藏節點
這是代碼。
HTML:
<div class="resultsContent">
<div class="demo" id="demo_1">
<ul>
{% for ipc in ipcs %}
{% ifequal ipc.back_list 1 %}
</ul></li>
{% endifequal %}
{% ifequal ipc.kind "c" %}
<li id="{{ ipc.symbol }} cat" rel="node-type">
{% else %}
<li id="{{ ipc.symbol }} cat" rel="node-type">
{% endifequal %}
{% endfor %}
</ul>
</div>
</div>
腳本:
jQuery('#demo_1')
.jstree({
plugins : [ "themes", "html_data", "checkbox" ],
themes : { theme: "default", dots : false, icons : false },
core : { "initially_open" : [ "{{ top_symbol }}" ] },
})
$("#cat").slice(5, 10).hide(); //Hide some nodes
感謝托馬斯,我試過,但似乎把id中的「cat」與jstree衝突。我將不得不以其他方式選擇li元素。 – mxm 2010-09-14 14:16:33
在這種情況下,請嘗試使用子選擇器(http://api.jquery.com/child-selector/):選擇「demo_1」DIV下的所有LI項目:$('#demo_1> li') – 2010-09-14 14:25:55
它工作正常!,格拉西亞托馬斯! – mxm 2010-09-14 14:57:55