HTML DOM
The createTBody() method of the HTMLTableElement interface creates a tbody element, inserts it immediately after the last tbody element child of the given table, or as the last child if there is no such element, and returns it.
This method creates and inserts the element directly, without requiring separate calls to methods such as Document.createElement(), Node.insertBefore(), and Node.appendChild().
[!NOTE] Unlike HTMLTableElement.createTHead() and HTMLTableElement.createTFoot(),
createTBody()always creates a new<tbody>element, even if the table already contains one or more bodies.
Syntax
createTBody()
Parameters
None.
Return value
An HTMLTableSectionElement (which is always a tbody).
Examples
const myBody = myTable.createTBody();
// Now this should be true: myBody === myTable.tBodies.item(myTable.tBodies.length - 1)
Specifications
Browser compatibility
See also
- HTMLTableElement.createCaption()
- HTMLTableElement.createTFoot()
- HTMLTableElement.createTHead()
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
