The parse() static method of the CSSNumericValue interface converts a value string into an object whose members are value and the units.
The parse() static method of the CSSNumericValue interface converts a value string into an object whose members are value and the units.
js
CSSNumericValue.parse(cssText)
cssTexta string containing numeric and unit parts.
The following returns a CSSUnitValue object with a unit property equal to "px" and a value property equal to 42.
js
let numValue = CSSNumericValue.parse("42.0px");
| Specification |
|---|
| CSS Typed OM Level 1 # dom-cssnumericvalue-parse |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
parse_static |
66Not exposed to PaintWorklet. |
79Not exposed to PaintWorklet. |
No | No | 53Not exposed to PaintWorklet. |
16.4 | 66Not exposed to PaintWorklet. |
66Not exposed to PaintWorklet. |
No | 47Not exposed to PaintWorklet. |
16.4 | 9.0Not exposed to PaintWorklet. |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/parse_static