HTMLTableElement: createTHead() method
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
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
| Specification |
|---|
| HTML> # dom-table-createthead-dev> |