Skip to content

Window.createSpan method

Window › createSpan

Official

Creates a new <span> element.

Signature:

createSpan(o?: string | DomElementInfo | undefined, callback?: ((el: HTMLSpanElement) => void) | undefined): HTMLSpanElement

Parameters:

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

Returns: HTMLSpanElementThe created element.

Example:

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