JavaScript Reference :: Table

The Table object can be created by retrieving an reference to a table tag in the HTML document (using getElementById) or by creating a reference to a Node object in a NodeList of table objects, for example, a NodeList created by getElementsByTagName("table").

Table

methods

Node createCaption()
Creates a caption for the table and returns the Node as a reference. To set the caption of the table, use the innerHTML property of the node.
Node createTFoot()
Creates a tFoot node and returns a reference.
Node createTHead()
Creates a tHead node and returns a reference.
void deleteCaption()
Removes the caption from the table.
void deleteRow(int index)
Deletes the row with the specified index
void deleteTFoot()
Deletes the tFoot node.
void deleteTHead()
Deletes the tHead node.
void insertRow(int index)
Inserts a new row at the specified index. Specifying an index of 0 inserts a new row at the top of the table, while specifying an index of -1 inserts a new row at the bottom of the table.

properties

border
The value provided in the border attribute of the HTML tag.
caption
The value provided in the caption tag. If no caption was created, in the HTML, a new caption object can be created by using the createCaption method.
cellPadding
The value provided in the cellpadding attribute of the HTML tag.
cells
An array containing all cells in the table.
cellSpacing
The value provided in the cellspacing attribute of the HTML tag.
className
The value provided in the class attribute of the HTML tag.
dir
The text direction of the element (i.e. ltr or rtl).
frame
The outer border of a table. Valid values are:
  • void
  • above
  • below
  • hsides
  • vsides
  • lhs
  • rhs
  • box
  • border
id
The value provided in the id attribute of the HTML tag.
lang
The language code associated with the object.
rows
An array containing all rows in the table.
rules
The inner border of a table. Valid values are:
  • none
  • groups
  • rows
  • cols
  • all
summary
The value provided in the summary attribute of the HTML tag.
tBodies
An array of body elements. This can be created using the TBODY HTML tag or by manipulating the array directly.
tFoot
The footer of the table. This can be created using the TFOOT HTML tag or by createTFoot.
tHead
The header of the table. This can be created using the THEAD HTML tag or by createTFoot.
title
The value provided in the title attribute of the HTML tag.
width
The value provided in the width attribute of the HTML tag.

events

onblur
onclick
ondblclick
onfocus
onkeydown
onkeypress
onkeyup
onmousedown
onmouseout
onmouseover
onmouseup
onresize