我目前正在使用 js 树,我想获取最后点击的复选框 ID 以及其他 ID。(我想获取特定的复选框 ID)。#tree 具有 ID 和名称
$("#tree").jstree("get_selected").each
                    (function () {
                        treeNodes.push(this.id);
                    });
这段代码没有给出任何 id。我该怎么做?
我目前正在使用 js 树,我想获取最后点击的复选框 ID 以及其他 ID。(我想获取特定的复选框 ID)。#tree 具有 ID 和名称
$("#tree").jstree("get_selected").each
                    (function () {
                        treeNodes.push(this.id);
                    });
这段代码没有给出任何 id。我该怎么做?
Javascript:
$(function () {
        $("#arbol").jstree({
               "plugins": ["ui", "html_data", "checkbox", "themes"]
        });
        $("#arbol").bind('change_state.jstree', function (e, data) {
               codigosCheckBoxs()
        });
});
function codigosCheckBoxs() {
        var codigosList = [];
        $("#arbol").jstree("get_checked", null, true).each(function () {
                 if (this.id.length > 0) {
                      codigosList.push(this.id);
                 }
        });
       alert('Ids: ' + codigosList)
}
HTML:
<div id="arbol">
<ul>
    <li><a>01 Sistema de Dirección</a>
        <ul>
            <li><a>0101 Volante de Dirección</a>
                <ul>
                    <li id="010101"> <a title="Estado y/o Fijación Deficiente">010101 Estado y/o Fijación Deficiente - G-M-L</a>
                    </li>
                    <li id="010102"> <a title="Juego Axial">010102 Juego Axial - G-M-L</a>
                    </li>
                    <li id="010103"> <a title="Juego Radial">010103 Juego Radial - G-M-L</a>
                    </li>
                </ul>
            </li>
        </ul>
    </li>
</ul>
演示: