The table is element x
. The first <tr>
is element tr
. Cells
in a <tbody>
have a grey border; other cells a black one.
th | This <tr> may be cloned. |
td |
---|---|---|
td in tbody | td in tbody | td in tbody |
td in tbody | td in tbody | td in tbody |
This page tests creation and deletion of table elements.
Click on a cell to see which table section it's part of.
var y = x.createCaption(); y.appendChild(document.createTextNode('Created caption'));
x.deleteCaption()
var y = x.createTFoot(); y.appendChild(tr.cloneNode(true)); alert(x.getElementsByTagName('tfoot').length)
var y = x.createTHead(); y.appendChild(tr.cloneNode(true)); alert(x.getElementsByTagName('thead').length)
x.deleteRow(0)
x.rows[0].deleteCell(0)
x.deleteTFoot()
x.deleteTHead()
var y = x.rows[0].insertCell(1); y.appendChild(document.createTextNode('Inserted cell'));
var y = x.insertRow(1); var z = document.createElement('td'); z.appendChild(document.createTextNode('Inserted row')); y.appendChild(z);
x.moveRow(0,2)