Get CSS property value with JS
Just a little reminder to myself about reading the value of a CSS property (variable) using javascript:
getComputedStyle(element).getPropertyValue('--myprop')
Of course, if the value is numeric, it’s going to have its unit attached, such as ‘10px’
Just strip it to have the pure number:
getComputedStyle(element).getPropertyValue('--myprop').replace('px', '')
Spotted a typo or (likely) a grammar error? Send a pull request.