CSSNumericValue: to() method
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Theto() method of theCSSNumericValue interface converts a numeric value from one unit toanother.
In this article
Syntax
js
to(unit)Parameters
unitThe unit to which you want to convert.
Return value
Exceptions
SyntaxErrorDOMExceptionThrown if an invalid type was passed to the method.
TypeErrorThrown if the passed values cannot be summed.
Examples
js
// Prints "0.608542cm"console.log(CSS.px("23").to("cm").toString());Specifications
| Specification |
|---|
| CSS Typed OM Level 1> # dom-cssnumericvalue-to> |