Javascript 如何从文本中获取子节点?
您能告诉我如何从文本中获取子节点吗?实际上,当用户单击该节点时,我可以获取子节点,并使用该节点获取子节点的值Javascript 如何从文本中获取子节点?,javascript,jquery,jstree,Javascript,Jquery,Jstree,您能告诉我如何从文本中获取子节点吗?实际上,当用户单击该节点时,我可以获取子节点,并使用该节点获取子节点的值 alert("node_children: " + data.node.children); 但是现在我有了一个按钮“getchild”,在其中我将获取静态文本“a”和“b”,当我只使用文本单击“a”和“b”的“child”按钮时,我需要获取child? 我能得到身份证而不是文本吗 改变 $('#child').click(function () { alert(
alert("node_children: " + data.node.children);
但是现在我有了一个按钮“getchild”,在其中我将获取静态文本“a”和“b”,当我只使用文本单击“a”和“b”的“child”按钮时,我需要获取child?
我能得到身份证而不是文本吗
改变
$('#child').click(function () {
alert('child of b');
});
到
你是说这样的事吗
$('#child').click(function (e) {
alert($('#tree').jstree('get_selected')[0])
});
我是否遗漏了什么,或者这可能像使用
console.log(item.text());
而不是
console.log(item.id);
根据API,您可以使用
$.jstree._reference('#tree').get_text(node);
文本节点没有子节点,你到底想干什么?@Mike'Pomax'Kamermans我只想要一切text@Mike“Pomax”Kamerman请检查我的更新,我可以获得id。现在我想要文本表单that@Mike“Pomax”Kamerman anwer应该是相同的,因为他们的文本和id是相同的same@Mike“Pomax”kamerman抱歉,我想在做了一些疯狂的实验后,我一次问了两个问题API,我终于让它显示文本。我不知道是否有更干净的方法[链接]
console.log(item.id);
$.jstree._reference('#tree').get_text(node);