Skip to content

createEl<K>

Creates an element and appends it to this node, or prepends it when o.prepend is set.

Import:

import 'obsidian-test-mocks/setup';

Signature:

function createEl(this: Node, tag: K, o: string | DomElementInfo | undefined, callback: ((el: HTMLElementTagNameMap[K]) => void) | undefined): HTMLElementTagNameMap[K]

Parameters:

Parameter Type Description
this Node
tag K The tag name of the element to create.
o string | DomElementInfo | undefined A class name, or the element’s options; any parent given there is replaced by this node.
callback ((el: HTMLElementTagNameMap[K]) => void) | undefined Called with the new element before it is returned.

Returns: HTMLElementTagNameMap[K] — The new element.