【问题标题】:How do I insert a dynamically generated element into a HTML table cell?如何将动态生成的元素插入到 HTML 表格单元格中?
【发布时间】:2023-02-20 09:13:07
【问题描述】:

给出下表:

<table>
<tr>
<td id="resultsTable"></td>
<td>content<td>
</tr>
</table>

我需要将动态生成的表插入到 resultsTable 单元格中。在 JS 中,它是用

var table = document.createElement("table");
table.setAttribute("class", "resultsTable");
table.setAttribute("id", "resultsTable");

表格永远不会插入到单元格中,动态生成的表格会影响 svg 地图。

【问题讨论】:

    标签: javascript html css


    【解决方案1】:
    var table = document.createElement("table");
    table.id = 'anotherTable'
    table.className = 'anotherTable'
    document.getElementById('resultsTable').appendChild(table);
    

    【讨论】:

      猜你喜欢
      • 2021-02-02
      • 1970-01-01
      • 2020-02-04
      • 1970-01-01
      • 2016-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多