Function: hasClass()
ts
function hasClass(el, className): boolean;Checks if an element has a specified CSS class, including SVG elements.
Parameters
| Parameter | Type | Description |
|---|---|---|
el | HTMLElement | SVGElement | The element to check |
className | string | The CSS class to check for |
Returns
boolean
If the element has the specified CSS class, returns true; otherwise, returns false.
Example
ts
const el = document.createElement('div')
el.className = 'example-class'
console.log(hasClass(el, 'example-class'))Since
1.0.0