获取layui tree 多选框的id值
若要获取layui tree多选框的id值,可以通过以下步骤:
- 在HTML中定义一个layui tree组件,并设置多选框的唯一标识(id)。
<div class="layui-tree" id="tree"></div>
- 在JavaScript中初始化layui tree,并添加监听事件。
layui.use('tree', function(){
var tree = layui.tree;
tree.render({
elem: '#tree',
showCheckbox: true,
... // 其他配置项
});
tree.on('checkbox(tree)', function(obj){
console.log(obj.data.id); // 输出多选框的id值
});
});
在上述代码中,通过tree.on('checkbox(tree)', ...)添加了一个监听事件,当多选框的选中状态发生变化时,会触发该事件并输出多选框的id值。其中obj.data.id表示当前选中的多选框的id值。
通过以上步骤,可以获取到layui tree多选框的id值
原文地址: http://www.cveoy.top/t/topic/iZOS 著作权归作者所有。请勿转载和采集!