Add new rows/columns to a table

点点圈 提交于 2019-12-11 05:16:00

问题


I have this code already:

for (i=0;i<names.length;i++) {
    var row = document.createElement('tr');
    var col = document.createElement('td');
    col.appendChild(document.createTextNode(names[i]));
    row.appendChild(col);
    document.getElementById('imagenametable').appendChild(row);
}

This is in Javascript. It does not seem to be adding anything to my table (which has an ID of imagenametable. What is wrong? And yes, I do intend to just make rows of text in a table.


回答1:


You should inverse the two script tags : always load your libraries before any other scripts that uses them.



来源:https://stackoverflow.com/questions/12867533/add-new-rows-columns-to-a-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!