Skip to content

createSpan

Official

Creates a new <span> element.

Signature:

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

Parameters:

Parameter Type Description
o? DomElementInfo | string The options object.
callback? (el: HTMLSpanElement) => void A 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: