W3cubDocs

/Web APIs

HTMLTableElement: createTBody() method

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

js

createTBody()

Parameters

None.

Return value

Examples

js

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

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
createTBody 20 12 25 9 15 6 4.4 25 25 14 6 1.5

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableElement/createTBody