UseCreateElement
katanakit-js / useCreateElement
Function: useCreateElement()
Section titled “Function: useCreateElement()”function useCreateElement<T>(tagName, options?): HTMLElementTagNameMap[T];Defined in: infrastructure/dom/dom.service.ts:392
Creates a new HTML element.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Description |
|---|---|
T extends keyof HTMLElementTagNameMap |
The tag name from HTMLElementTagNameMap. |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
tagName |
T |
The tag name to create. |
options? |
ElementCreationOptions |
Optional element creation options. |
Returns
Section titled “Returns”HTMLElementTagNameMap[T]
The newly created element.
Throws
Section titled “Throws”If called outside a browser environment.
Example
Section titled “Example”const div = useCreateElement("div");const input = useCreateElement("input", { is: "custom-input" });