如何将 class 添加到 fancy tree jquery 中的 `li` 标签

how to add class to `li` tag in fancy tree jquery

如何将 class 添加到花式树 jquery 中的 li 标签。
我尝试使用 extraClasses 但它添加了 class 到 span 标签 谁能帮我?

 {title: "Node 2", folder: true, lazy: true, 
        treeMode: "struct", 
        keyType: "root", key: "_structtree_", 
        refKey: "_structtree_", 
        extraClasses: "scioStructureTree" }

拜托:)

我在重新设计 fancytree 时遇到了类似的问题。在研究了fancytree

的源码后找到了解决办法
$("<selector to your html element>").fancytree({
   ... other stuff ...
   renderNode: function(event, data) {
      setTimeout(function() {
          $(node.li).addClass("your className")
      }, 20);
   }
})

20 毫秒的超时确保节点完全呈现,因此 类 不会随呈现一起移除。

您可以将 node.li 用作普通 javascript 对象,$(node.li) 用作普通 JQuery 对象