Skip to content

Window.createDiv method

Window › createDiv

Official

Creates a new <div> element.

Signature:

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

Parameters:

ParameterTypeDescription
o?DomElementInfo | stringThe options object.
callback?(el: HTMLDivElement) => voidA 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' });
});