Returns a CSS declaration by its name.
- Source:
Methods
(static) getCSSDeclaration(className, returnTextopt) → {CSSStyleDeclaration|null}
- Source:
Example
import { getCSSDeclaration } from '@untemps/utils/dom/getCSSDeclaration'
const styleElement = document.createElement('style')
styleElement.textContent = '.drag { background-color: black; }'
document.head.appendChild(styleElement)
const className = '.drag'
const returnText = true
getCSSDeclaration(className, returnText) // background-color: black;
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
className |
string | The name of the CSS declaration to return. You may ignore the starting dot. |
||
returnText |
boolean |
<optional> |
false
|
|
Returns:
The CSS declaration or null if the CSS declaration is not found.
- Type
- CSSStyleDeclaration | null