layui tree 获取复选框选中节点的id

时间:2025-04-02 16:22:58
var treecheckdata = tree.getChecked('demoId'); var nodeIds = new Array(); nodeIds = getCheckedId(treecheckdata); // 测试 var permList = nodeIds; console.log("permList:"+permList); // 获取选中节点的id function getCheckedId(jsonObj) { var id = ""; $.each(jsonObj, function (index, item) { if (id != "") { id = id + "," + item.id; } else { id = item.id; } var i = getCheckedId(item.children); if (i != "") { id = id + "," + i; } }); return id; }