THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Table tBodies Collection

Table Object Reference Table Object

Example

Find out how many <tbody> elements there are in a table:

var x = document.getElementById("myTable").tBodies.length;

The result of x will be:

2
Try it Yourself »

More "Try it Yourself" examples below.


Definition and Usage

The tBodies collection returns a collection of all <tbody> elements in a table.

Note: The elements in the collection are sorted as they appear in the source code.


Browser Support

Collection
tBodies Yes Yes Yes Yes Yes

Syntax

tableObject.tBodies

Properties

Property Description
length Returns the number of <tbody> elements in the collection.

Note: This property is read-only

Methods

Method Description
[index] Returns the <tbody> element from the collection with the specified index (starts at 0).

Note: Returns null if the index number is out of range
item(index) Returns the <tbody> element from the collection with the specified index (starts at 0).

Note: Returns null if the index number is out of range
namedItem(id) Returns the <tbody> element from the collection with the specified id.

Note: Returns null if the id does not exist

Technical Details

DOM Version: Core Level 2 Document Object
Return Value: An HTMLCollection Object, representing all <tbody> elements in the <table> element. The elements in the collection are sorted as they appear in the source code

Examples

More Examples

Example

[index]

Alert the innerHTML of the first <tbody> element (index 0) in the table:

alert(document.getElementById("myTable").tBodies[0].innerHTML;
Try it Yourself »

Example

item(index)

Alert the innerHTML of the first <tbody> element (index 0) in the table:

alert(document.getElementById("myTable").tBodies.item(0).innerHTML);
Try it Yourself »

Example

namedItem(id)

Alert the innerHTML of the <tbody> element with id="myTBody" in the table:

alert(document.getElementById("myTable").tBodies.namedItem("myTBody").innerHTML);
Try it Yourself »

Related Pages

HTML reference: HTML <tbody> tag


Table Object Reference Table Object