tbody, tfoot, thead | NN 6 IE 4 DOM 1 | |||||
The tbody, tfoot, and thead objects reflect the tbody, tfoot, and thead elements, respectively. For scripting purposes, you can treat each of these as a container of row groups inside a table. They all share the same properties and methods, so you need to keep their HTML functionality straight as you script these elements. A table can have only one tfoot and one thead element, but multiple tbody elements. Also, by default, Internet Explorer 4 or later and Netscape 6 create a tbody object for every table even if you don't include one in your table's source code. This default tbody element encompasses all rows of the table (except those you have wrapped inside thead or tfoot elements, if any). Although these objects are implemented in IE 4 for the Macintosh, they are incomplete. Moreover, the row insertion operations noted in the table element are just as strange for these objects under IE 4 for the Mac. |
||||||
HTML Equivalent | ||||||
<tbody> <tfoot> <thead> |
||||||
Object Model Reference | ||||||
[window.]document.getElementById("elementID") [window.]document.getElementById("tableID").tBodies[i] [window.]document.getElementById("tableID").tfoot [window.]document.getElementById("tableID").thead |
||||||
Object-Specific Properties | ||||||
|
||||||
Object-Specific Methods | ||||||
|
||||||
Object-Specific Event Handler Properties | ||||||
None. |
align | NN 6 IE 4 DOM 1 |
Read/Write | |
Defines the horizontal alignment of content within all cells contained by the tbody element. |
|
Example | |
document.getElementById("myTbody").align = "center"; |
|
Value | |
One of the three horizontal alignment string constants: center | left | right. |
|
Default | |
left |
bgColor | NN 6 IE 4 DOM n/a |
Read/Write | |
Specifies the background color of the cells contained by the tbody, tfoot, or thead element. This color setting is not reflected in the style sheet backgroundColor property. Even if the bgcolor attribute or bgColor property is set with a plain-language color name, the returned value is always a hexadecimal triplet. |
|
Example | |
document.getElementById("myTable").tHead.bgColor = "yellow"; |
|
Value | |
A hexadecimal triplet or plain-language color name. See Appendix A for acceptable plain-language color names. |
|
Default | |
Varies with browser and operating system. |
ch | NN 6 IE 5(Mac)/6(Win) DOM 1 |
Read/Write | |
Defines the text character used as an alignment point for text within a column or column group (reflecting the char attribute). This property is normally of value only for the align attribute set to "char". In practice, neither IE nor Navigator responds to these properties. |
|
Example | |
document.getElementById("myTBody").ch = "."; |
|
Value | |
Single character string. |
|
Default | |
None. |
chOff | NN 6 IE 5(Mac)/6(Win) DOM 1 |
Read/Write | |
Defines the offset point at which the character specified by the char attribute is to appear within a cell. In practice, neither IE nor Navigator responds to these properties. |
|
Example | |
document.getElementById("myTBody").chOff = "80%"; |
|
Value | |
String value of the number of pixels or percentage (within the cell). |
|
Default | |
None. |
rows | NN 6 IE 4 DOM 1 |
Read-only | |
Returns a collection of tr elements inside the table section. You can also get a group of rows for an entire table in IE for Windows. |
|
Example | |
var allTableRows = document.getElementById("myTFoot").rows; |
|
Value | |
Reference to a rows collection object. |
|
Default | |
Array of zero length. |
vAlign | NN 6 IE 4 DOM 1 |
Read/Write | |
Specifies the manner of vertical alignment of text within the cells contained by the tbody, tfoot, or thead element. |
|
Example | |
document.getElementById("myTbody").vAlign = "baseline"; |
|
Value | |
Case-insensitive constant (as a string): baseline | bottom | middle | top. |
|
Default | |
middle |
deleteRow( ) | NN 6 IE 4 DOM 1 |
deleteRow(index) | |
Removes a tr element nested within the current tbody, tfoot, or thead element. The integer parameter points to the zero-based item in the section's rows collection. To repopulate a table section with new or sorted content, empty the section with iterative calls to the deleteRow( ) method: |
|
Parameters | |
|
|
Returned Value | |
None. |
insertRow( ) | NN 6 IE 4(Win) DOM 1 |
insertRow(index) | |
Inserts a tr element nested within the current tbody, tfoot, or thead element. The integer parameter points to the zero-based index in the rows collection where the new row should go, but in IE you can also use the shortcut value of -1 to append the row to the end of the collection. Adding the row inserts an empty element, to which you add cells via the insertCell( ) method. Unfortunately, scripting the addition of table rows and cells in IE for the Macintosh (including Version 5.1) is very broken, yielding elephantine row and cell dimensions. For nonnested tables, you might be able to get away with regular document tree node creation and insertion instead of the table section object convenience methods. |
|
Parameters | |
|
|
Returned Value | |
Reference to the newly inserted row. |
moveRow( ) | NN n/a IE 5(Win) DOM n/a |
moveRow(indexToMove, destinationIndex) | |
Moves a row in the tbody, tfoot, or thead element from its original location to a different row position within the same section. The first parameter is a zero-based index of the row (within the rows collection) you wish to move. The second parameter is the index of the row before which you want to move the row. |
|
Parameters | |
|
|
Returned Value | |
Reference to the moved row. |