Table tBodies Collection

Definition and Usage

tBodies The collection returns all <tbody> elements of the collection.

Comment:The elements in the collection are sorted in the order they appear in the source code.

See also:

HTML Reference Manual:HTML <tbody> Tag

Example

Example 1

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

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

Try it yourself

The result of x will be:

2

Example 2: [index]

Prompt the innerHTML of the first <tbody> element (index 0):

alert(document.getElementById("myTable").tBodies[0].innerHTML;

Try it yourself

Example 3: item(index)

Prompt the innerHTML of the first <tbody> element (index 0):

alert(document.getElementById("myTable").tBodies.item(0).innerHTML);

Try it yourself

Example 4: namedItem(id)

Prompt the innerHTML of the <tbody> element with id="myTBody":

alert(document.getElementById("myTable").tBodies.namedItem("myTBody").innerHTML);

Try it yourself

Syntax

tableObject.tBodies

Property

Property Description
length

Returns the number of <tbody> elements in the collection.

Comment:This property is read-only.

Method

Method Description
[index]

Returns the <tbody> element at the specified index in the collection (starting from 0).

Comment:Returns null if the index is out of range.

item(index)

Returns the <tbody> element at the specified index in the collection (starting from 0).

Comment:Returns null if the index is out of range.

namedItem(id)

returning from the collection with the specified id of the <tbody> element.

Comment:If id Returns null if not present.

Technical Details

DOM Version: Core Level 2 Document Object
Return Value:

HTMLCollection Object, representing all <tbody> elements within the <table> element.

The elements in the collection are sorted in the order they appear in the source code.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support