Skip to content

Function: getClass()

ts
function getClass(el): string;

Returns a string of all the CSS class names assigned to an element, including SVG elements.

Parameters

ParameterTypeDescription
elHTMLElement | SVGElement | null | undefinedThe element to retrieve the class names from

Returns

string

A string containing class names

Example

ts
const el = document.querySelector('.example-class')!;
const classes = getClass(el);
classes // => 'example-class'

Since

1.0.0

Released under the MIT License.