[英]Get node by Id in jstree
我有ID,需要獲取相應的節點。
但是如何?
在這里,“ n”是我的節點ID。 如何獲取jstree對象?
$.each(data.node.children,function(k,v){
var n = $("#jstree_demo_div").find("[id='"+v+"']");
console.log(n);
});
問候。
要獲取對DOMElement的引用,您只需要在jQuery對象上調用.get(0)
。
$.each(data.node.children,function(k,v){
var n = $("#jstree_demo_div").find("[id='"+v+"']").get(0);
console.log(n);
});
除非使用無效的html,否則可以將其縮短為以下內容:
$.each(data.node.children,function(k,v){
var n = $('#'+v).get(0);
console.log(n);
});
解決了。
我不必按ID來獲取節點。
我得到父級的JSON並找到子級。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.