HTML DOM
The createTHead() method of the HTMLTableElement interface creates a thead element, inserts it before the first element child of the given table that's neither a caption nor a colgroup, or as the last child if no such insertion location is found, and returns it. If the table already has a <thead> element child, this method returns the first such child without creating one.
When creation is needed, this method creates and inserts the element directly, without requiring separate calls to methods such as Document.createElement() and Node.insertBefore().
Syntax
createTHead()
Parameters
None.
Return value
An HTMLTableSectionElement (which is always a thead).
Examples
const myHead = myTable.createTHead();
// Now this should be true: myHead === myTable.tHead
Specifications
Browser compatibility
See also
- HTMLTableElement.createCaption()
- HTMLTableElement.createTBody()
- HTMLTableElement.createTFoot()
- HTMLTableElement.deleteTHead()
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
