向表中添加新行/列 [英] Add new rows/columns to a table

查看:148
本文介绍了向表中添加新行/列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经有了这个代码:

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);
}

这是在Javascript中。它似乎没有向我的表添加任何内容(其ID为 imagenametable 。有什么问题?是的,我确实打算在一个文本中创建一行文本表。

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.

推荐答案

您应该反转两个脚本标记:始终在使用它们的任何其他脚本之前加载库。

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

这篇关于向表中添加新行/列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆