Skip to content

Function: createDom()

ts
function createDom<K>(domAttrs?): HTMLElementTagNameMap[K];

Creates a new DOM element based on the provided attributes.

Type Parameters

Type Parameter
K extends keyof HTMLElementTagNameMap

Parameters

ParameterTypeDescription
domAttrs?DomAttrs<K>Optional attributes for the new element.

Returns

HTMLElementTagNameMap[K]

The newly created element.

Example

ts
const myDiv = createDom({
  tagName: 'div',
  node: 'Hello, world!',
  container: document.body
})
console.log(myDiv.textContent)

Since

1.0.0

Released under the MIT License.