如何使用jstree的复选框插件获取选中id列表?
var result = new Array();
$(".jstree-checked").each(function(i, element){
result[i] = $(element).attr("id");
});
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(",");
//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"> </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>
http://www.jstree.com/documentation/checkbox
.get_checked ( context, get_all ), .get_unchecked ( context, get_all )
(在那个页面的底部)