Skip to content

createSvg<K>

Official

Creates a new svg element such as <svg>, <circle>, <rect>, etc.

Signature:

function createSvg(tag: K, o?: string | SvgElementInfo, callback?: (el: SVGElementTagNameMap[K]) => void): SVGElementTagNameMap[K]

Parameters:

Parameter Type Description
tag K The tag name of the element to create.
o? string | SvgElementInfo The options object.
callback? (el: SVGElementTagNameMap[K]) => void A callback function to be called when the element is created.

Returns: SVGElementTagNameMap[K] — The created element.

Example:

createSvg('svg', { cls: 'foo bar' }, (svg) => {
svg.createSvg('circle');
});

Links to this page: