HTMLTableElement.createTBody()

The createTBody() method of HTMLTableElement objects creates and returns a new <tbody> element associated with a given <table>.

Note: Unlike HTMLTableElement.createTHead() and HTMLTableElement.createTFoot(), createTBody() systematically creates a new <tbody> element, even if the table already contains one or more bodies. If so, the new one is inserted after the existing ones.

Syntax

table.createTBody();

Return value

HTMLTableSectionElement

Example

let mybody = mytable.createTBody();
// Now this should be true: mybody == mytable.tBodies.item(mytable.tBodies.length - 1)

Specifications

Specification
HTML Standard
# dom-table-createtbody-dev

Browser compatibility

BCD tables only load in the browser