このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

StylePropertyMapReadOnly.keys()

Limited availability

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

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

StylePropertyMapReadOnly.keys() メソッドは、 StylePropertyMapReadOnly の各項目のキーを含む新しい配列イテレーターを返します。

構文

js
StylePropertyMapReadOnly.keys();

引数

なし。

返値

新しい Array です。

この例では、 keys() メソッドを使用して Element.computedStyleMap() の中にあるプロパティにアクセスすることができます。

js
// button 要素を取得
const buttonEl = document.querySelector("button");

// すべての計算済みスタイルを `computedStyleMap` で受け取る
const allComputedStyles = buttonEl.computedStyleMap();

// keys はプロパティの反復可能なリストを返す
const props = allComputedStyles.keys();
console.log(props.next().value); // align-content を返す

仕様書

This feature does not appear to be defined in any specification.

ブラウザーの互換性