StylePropertyMapReadOnly.forEach()

Limited availability

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

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

StylePropertyMapReadOnly.forEach() メソッドは、指定された関数を StylePropertyMapReadOnly のそれぞれの要素に対して 1 回ずつ呼び出します。

構文

js
StylePropertyMapReadOnly.forEach(function callback(currentValue[, index[, array]]) {
    //コード
}[, thisArg]);

引数

callback

それぞれの要素に対して呼び出す関数であり、 3 つの引数を取ります。

currentValue

処理しようとしている現在の要素の値です。

index省略可

処理しようとしている現在の要素の位置です。

array省略可

forEach() が呼び出された StylePropertyMapReadOnly です。

thisArg 省略可

callback を実行するときに this として使用する値(すなわち、 Object への参照)です。

返値

undefined です。

こちらは、 forEach()Element.computedStyleMap() の結果に対して使用する例です。

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

// `computedStyleMap` ですべての計算済みスタイルが取得できます
const allComputedStyles = buttonEl.computedStyleMap();

// forEach ですべてのプロパティ/値の組に対してコードを実行することができます
allComputedStyles.forEach((elem, index, arr) => {
  // code to run for each pair
});

仕様書

No specification found

No specification data found for api.StylePropertyMapReadOnly.forEach.
Check for problems with this page or contribute a missing spec_url to mdn/browser-compat-data. Also make sure the specification is included in w3c/browser-specs.

ブラウザーの互換性

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
forEach

Legend

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

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