treeview目录通过javascript获取路径

gg0vcinb  于 2021-09-23  发布在  Java
关注(0)|答案(0)|浏览(232)

我有一个由php动态创建的结构

<ul class="mainFolder">
  <li class="subFolder"><span id="LKKADSO" onclick="hideFolder(this.id)" class="folderExpander">+ </span><span class="subFolderSpan">LKKADSO</span>
    <ul class="mainFolder">
      <li class="subFolder"><span id="ISUDFU" onclick="hideFolder(this.id)" class="folderExpander" style="font-size: 1.2em;">- </span><span class="subFolderSpan">ISUDFU</span>
        <ul class="mainFolder" style="display: none;">
          <li class="subFolder"><span id="DDAASS" onclick="hideFolder(this.id)" class="folderExpander">+ </span><span class="subFolderSpan">DDAASS</span></li>
        </ul>
      </li>
      <li class="subFolder"><span id="POOFGHO" onclick="hideFolder(this.id)" class="folderExpander">+ </span><span class="subFolderSpan">POOFGHO</span>
        <ul class="mainFolder">
          <li class="subFolder"><span id="sdaaasd" onclick="hideFolder(this.id)" class="folderExpander">+ </span><span class="subFolderSpan">sdaaasd</span></li>
        </ul>
      </li>
    </ul>
  </li>
  <li class="subFolder"><span id="lsflk" onclick="hideFolder(this.id)" class="folderExpander">+ </span><span class="subFolderSpan">lsflk</span>
    <ul class="mainFolder">
      <li class="subFolder"><span id="5844" onclick="hideFolder(this.id)" class="folderExpander">+ </span><span class="subFolderSpan">5844</span></li>
    </ul>
  </li>
</ul>

我的JavaCScript代码

function hideFolder(ID){

    element = document.getElementById(ID);

    if ( element.nextSibling.nextSibling.style.display == "none"){
        element.innerHTML = "+ ";
        element.nextSibling.nextSibling.style.display = "";

    }   

    else {
        element.nextSibling.nextSibling.style.display = "none";
        element.innerHTML = "- ";

    }

    /* Alternatif yöntem */
    /*if ($("#"+ID).next().next().css("display") == "none"){
        $("#"+ID).next().next().css("display","");
    }   

    else {
        $("#"+ID).next().next().css("display","none");;
    }*/

}

货物堆装与系固安全操作规则

.rootFolder{

    margin: 0;
    padding: 0;
    cursor:pointer;
}

.subFolder{
    /*margin-left: 2.5em;*/
    /* list-style: square inside url("Folder-icon.png");*/
    list-style-type: none;

    padding-left:2.5em;
    /*list-style-type: disc;*/
}
.mainFolder{
    padding:0 ;
}

  .subFolderSpan:hover{
      background-color: aquamarine;

  }

  .folderExpander{
      font-weight: 800;
      font-size: 1.2em;
  }

你可以在这里看到所有的代码。在这个网站上,js代码不起作用,但在我的电脑上它起作用了。
我想这样做:当我点击任何文件夹或任何文本时,我想得到所有路径。例如,我单击了isudfu文件夹,我想获取lkkadso/isudfu,或者我单击了5844,我想获取lkkadso/lsflk/5844
我怎么做呢?
这是树视图的截图

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题