StylePropertyMapReadOnly.getAll()

Limited availability

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

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

getAll()StylePropertyMapReadOnly インターフェイスのメソッドで、指定されたプロパティの値を含む CSSStyleValue オブジェクトの配列を返します。

構文

js
var cssStyleValues[] = StylePropertyMapReadOnly.getAll(property)

引数

property

すべての値を取得するプロパティの名前です。

返値

CSSStyleValue オブジェクトの配列です。

以下の例では、 getAll() を使用して background-image プロパティに対して使用しています。宣言されているそれぞれの背景画像の項目が入った Array を返します。

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

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

// getAll() を background-image プロパティに対して使用
const allBkImages = allComputedStyles.getAll("background-image");
console.log(allBkImages); // それぞれの背景画像を項目とした配列を出力

仕様書

Specification
CSS Typed OM Level 1
# dom-stylepropertymapreadonly-getall

ブラウザーの互換性

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
getAll

Legend

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

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