如何使用复选框插件从jstree获取已检查的ID列表?

时间:2010-05-12 11:05:00

标签: jquery jstree

如何使用复选框插件从jstree获取已检查的ID列表?

4 个答案:

答案 0 :(得分:0)

var result = new Array();
$(".jstree-checked").each(function(i, element){
    result[i] = $(element).attr("id");
}); 

答案 1 :(得分:0)

var arr = new Array();
var i = 0;
$('#dtree_region li').filter('.jstree-checked').each(function(){
                     arr[i] = $.makeArray($(this).attr("id"));
                    //  sel_id = sel_id + ',' + $(this).attr("id");
                        i++;
                        });
var sel_id = arr.join(",");

答案 2 :(得分:0)

//static.jstree.com/3.3.11/assets/dist/jstree.min.js 我在用

var ids = new Array();
$(".jstree-clicked").each(function(i, element){
   ids[i] = $(element).parent('li.jstree-node ').attr('id');
});

节点:

<li role="none" id="91" class="jstree-node  jstree-closed" aria-selected="true">
  <div unselectable="on" role="presentation" class="jstree-wholerow jstree-wholerow-clicked">&nbsp;</div>
  <i class="jstree-icon jstree-ocl" role="presentation"></i>
  <a class="jstree-anchor jstree-clicked" href="#" tabindex="-1" role="treeitem" aria-selected="true" aria-level="1" aria-expanded="false" id="91_anchor" style="touch-action: none; user-select: none;">
    <i class="jstree-icon jstree-checkbox" role="presentation"></i>
    <i class="jstree-icon jstree-themeicon" role="presentation"></i>Аксессуары</a>
</li>

答案 3 :(得分:-1)

http://www.jstree.com/documentation/checkbox

.get_checked ( context, get_all ), .get_unchecked ( context, get_all )

(在该页面的底部)