CSSKeywordValue: CSSKeywordValue() コンストラクター
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
CSSKeywordValue()
コンストラクターは、新しい CSSKeywordValue
オブジェクトを生成します。これは CSS のキーワードおよびその他の識別子を表します。
構文
js
new CSSKeywordValue(val)
引数
value
-
新しい
CSSKeywordValue
の値に設定または返却します。
例外
TypeError
-
value
引数が指定されていなかったり、文字列型ではなかったりした場合。
例
次の例は、CSS の display
プロパティを既定値にリセットするために、インラインの style
属性を style="display: initial"
に設定します。これは開発者ツールインスペクターで見られます。
js
const keyword = new CSSKeywordValue("initial");
const myElement = document.getElementById("myElement").attributeStyleMap;
myElement.set("display", keyword);
console.log(myElement.get("display").value); // 'initial'
console.dir(keyword);
仕様書
Specification |
---|
CSS Typed OM Level 1 # dom-csskeywordvalue-csskeywordvalue |
ブラウザーの互換性
BCD tables only load in the browser