Skip to content

createSpan

Official

Creates a new <span> element.

Example:

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

Signature:

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

Parameters:

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

Returns: HTMLSpanElement — The created element.

Example:

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

Links to this page: