情况:<li class="active"><a href="#server1" data-toggle="tab">server1</a></li>

试用JS代码来添加到HTML中。

        var li = document.createElement("li");
        if(index==0){
            li.className = "active";
        }
        var a1 = document.createElement("a");
        a1.href = "#server"+serverID;
        a1.id = "aServer"+serverID;

     //a1.data-toggle = "tab";不能使用“.data-toggle”,不能识别“-”; a1.dataset.toggle = "tab";
a1.innerText = "server"+serverID; li.appendChild(a1); var tab = document.getElementById("navTab"); tab.appendChild(li);

  

相关文章:

  • 2021-10-04
  • 2021-12-15
  • 2021-12-19
  • 2021-11-05
  • 2021-12-06
  • 2021-12-07
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-16
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
  • 2021-08-12
  • 2022-12-23
相关资源
相似解决方案