W3C DOM tests - Creating and deleting table elements

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.

Test scripts

createCaption() and deleteCaption()

var y = x.createCaption();
y.appendChild(document.createTextNode('Created caption'));
x.deleteCaption()

createTFoot() and createTHead()

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)

deleteCell() and deleteRow()

x.deleteRow(0)
x.rows[0].deleteCell(0)

deleteTHead() and deleteTFoot()

x.deleteTFoot()
x.deleteTHead()

insertCell() and insertRow()

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

moveRow()

x.moveRow(0,2)