CSSNumericValue: `parse()` statische Methode

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Die parse() statische Methode der CSSNumericValue Schnittstelle konvertiert einen Wertstring in ein Objekt, dessen Mitglieder Wert und Einheiten sind.

Syntax

js
CSSNumericValue.parse(cssText)

Parameter

cssText

ein String, der numerische und Einheitsteile enthält.

Rückgabewert

Ausnahmen

SyntaxError DOMException

TBD

Beispiele

Das Folgende gibt ein CSSUnitValue Objekt mit einer unit Eigenschaft zurück, die "px" entspricht, und einer value Eigenschaft, die 42 entspricht.

js
let numValue = CSSNumericValue.parse("42.0px");

Spezifikationen

Specification
CSS Typed OM Level 1
# dom-cssnumericvalue-parse

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
parse() static method

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.