打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
jsTree获取选中节点和选中指定节点

jstree获取当前选中的checkbox和获取选中节点的所有节点

首先初始化一个带有复选框的 jstree

$('#demo_tree').jstree({    "core" : {        'data': [           { "id" : "ajson1", "parent" : "#", "text" : "Simple root node"},           { "id" : "ajson2", "parent" : "#", "text" : "Root node 2" },           { "id" : "ajson3", "parent" : "ajson2", "text" : "Child 1" },           { "id" : "ajson4", "parent" : "ajson2", "text" : "Child 2" },        ]    },    "plugins" : ['checkbox'],});

jstree获取当前选中节点

这时分为两种选中,一个是点击也就是鼠标单击 节点 而不是 checkbox 的选中

var treeNode = $('#demo_tree').jstree(true).get_selected(true); //获取所有选中的节点对象

 同理获取 checkbox 的选中

var treeNode = $('#demo_tree').jstree(true).get_checked(true); //获取所有 checkbox 选中的节点对象

jstree选中指定的节点

// id 是选中的节点 id,然后后面的一个参数 true 表示的是不触发默认select_node.change的事件var id = 'ajson1';$('#schema_tree').jstree('select_node', id , true);

checkbox 同理。

 

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
js树
JQuery的JSTree(下篇)
jstree 使用API | 学步园
easyui tree 节点选中
jQuery zTree
EXT 前台分页,切换Store
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服