Methods
cssValueToNumber(value) → {Number|NaN}
Converts a CSS-value to a number without unit. If the base number is an integer the result will also be an integer, float values will also be converted correctly.
Parameters:
Name | Type | Description |
---|---|---|
value |
String | the css-value to convert |
Returns:
true number representation of the given value or NaN if the value is not parsable
- Type
- Number | NaN
Example
document.querySelector('main').style.setProperty('width', '99vh');
cssValueToNumber(document.querySelector('main').style.getPropertyValue('width'));
=> 99