Doorknob Doorknob - 1 month ago 11
Javascript Question

Add new rows/columns to a table

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.

Answer

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

Comments