HTMLTableElement: createTBody() method
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{APIRef("HTML DOM")}}
The **createTBody()** method of the {{domxref("HTMLTableElement")}} interface creates a {{HTMLElement("tbody")}} element, inserts it immediately after the last {{HTMLElement("tbody")}} element child of the given {{HTMLElement("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 {{domxref("Document.createElement()")}}, {{domxref("Node.insertBefore()")}}, and {{domxref("Node.appendChild()")}}.
توجه: Unlike {{domxref("HTMLTableElement.createTHead()")}} and {{domxref("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 {{domxref("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
{{Specifications}}
Browser compatibility
{{Compat}}
See also
- {{domxref("HTMLTableElement.createCaption()")}}
- {{domxref("HTMLTableElement.createTFoot()")}}
- {{domxref("HTMLTableElement.createTHead()")}}