Get computed CSS property in JavaScript
27 September 2022 (Updated 27 September 2022)
// Define helper function
function getComputedCss(element: Element | null, property: string) {
if (element) {
return window.getComputedStyle(element, null).getPropertyValue(property)
}
}
// Use function
getComputedCss(document. Body, 'font-family')
Sources
Thanks for your comment 🙏. Once it's approved, it will appear here.
Leave a comment