Skip to content

createDiv

Official

Creates a new <div> element.

Example:

createDiv({ text: 'foo' }, (div) => {
div.createEl('strong', { text: 'bar' });
});

Signature:

function createDiv(o: string | DomElementInfo | undefined, callback: ((el: HTMLDivElement) => void) | undefined): HTMLDivElement

Parameters:

ParameterTypeDescription
ostring | DomElementInfo | undefinedThe options object.
callback((el: HTMLDivElement) => void) | undefinedA callback function to be called when the element is created.

Returns: HTMLDivElement — The created element.

Example:

createDiv({ text: 'foo' }, (div) => {
div.createEl('strong', { text: 'bar' });
});

Links to this page: