1. Computing & Technology

JavaScript By Example

DOM Table: 3. Table Heading

From , former About.com Guide

The property and two methods that allow the caption to be processed have corresponding properties and methods for the thead node. You can directly access the thead node using the tHead property and the createTHead() and deleteTHead() methods allow you to add or delete the entire thead node in one call. As with the caption node a table can only have one thead node but unlike a caption a thead contains other tags.

If the following JavaScript is attached to the HTML from our first DOM table example it will add an extra row of empty cells after the existing heading row.


var mytable, newrow;
mytable = document.getElementById('mytab');
newrow = mytable.tHead.insertRow(-1);
newrow.insertCell(0);
newrow.insertCell(1);
newrow.insertCell(2);

©2012 About.com. All rights reserved.

A part of The New York Times Company.