在 js_tree 中有.check_node ( node )
和.uncheck_node ( node )
功能,我认为这就是你所要求的。在这里查看文档:http: //www.jstree.com/documentation/checkbox
这是上面链接中文档的摘录,“如何执行操作”:
/* METHOD ONE */
jQuery("some-selector-to-container-node-here")
.jstree("operation_name" [, argument_1, argument_2, ...]);
/* METHOD TWO */
jQuery.jstree._reference(needle)
/* NEEDLE can be a DOM node or selector for the container or a node within the container */
.operation_name([ argument_1, argument_2, ...]);
所以我认为这种语法应该有效
$.jstree._reference(".colors").check_node('li#tree_3');
另外我不确定你应该使用一个类来引用你的树。可能使用 ID 来引用您的树,然后使用以下语法:
$.jstree._reference("#colors").check_node('li#tree_3');
//编辑:请记住,最新版本的 jsTree 不再具有名为 _reference 的函数。它被重命名为引用(没有前导下划线)。(最后由@mkli90 于 24/08/2015 15:45 检查)链接:https ://www.jstree.com/api/#/?f= $.jstree.reference(needle)