Php 将自定义类添加到jstree
我需要向jstree中的所有子节点和父节点添加一个类 尝试了下面的代码,但不起作用Php 将自定义类添加到jstree,php,css,html,jquery-plugins,jstree,Php,Css,Html,Jquery Plugins,Jstree,我需要向jstree中的所有子节点和父节点添加一个类 尝试了下面的代码,但不起作用 $('#data').jstree({ 'core' : { 'data' : [{"text" : "GROUPS","state":{"opened":true}, "children" : [{ "text" : "USERS", attributes : { class : "desired_node_class" }}
$('#data').jstree({
'core' : {
'data' : [{"text" : "GROUPS","state":{"opened":true},
"children" : [{ "text" : "USERS", attributes : { class : "desired_node_class" }},{ "text" : "ADMIN"}]}
]
}
});
我做错了什么?。
这是一把小提琴
有人能纠正我吗
提前谢谢 试试这个:
element.classList.add("desired_node_class");
您需要在JSON中使用文档中指定的
li_attr
而不是attr
。这是你最新的小提琴:
我根据您的要求向所有节点添加了类-您必须包含每个节点的类数据
顺便说一句,如果您只是尝试为某些内容设置样式,那么最好不要添加自定义类,而是使用每个节点上已有的CSS类:
#data .jstree-node { } /* this is for each LI node */
#data .jstree-anchor { } /* this is for each A node */
向DOM元素添加类与向jstree节点添加类无关。