CSSNumericValue.parse()

Limited availability

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

Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。

parse()CSSNumericValue インターフェイスのメソッドで、値の文字列をメンバーが値と単位となっているオブジェクトに変換します。

構文

js
parse(cssText);

引数

cssText

数値と単位の部分を持つ文字列です。

返値

CSSNumericValue です。

例外

SyntaxError DOMException

TBD

以下は、unit プロパティが "px" で、value プロパティが 42 である CSSUnitValue オブジェクトを返すものです。

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

仕様書

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

ブラウザーの互換性

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.