StylePropertyMapReadOnly.has()

Limited availability

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

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

has()StylePropertyMapReadOnly インターフェイスのメソッドで、指定されたプロパティが StylePropertyMapReadOnly オブジェクトにあるかどうかを示します。

構文

js
var boolean = StylePropertyMapReadOnly.has(property);

引数

property

プロパティの名前です。

返値

論理値です。

ここでは、 has() メソッドを使用して、 padding-top プロパティが button 要素の style 属性に存在するかどうかを確認します。

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

// style 属性内のものを attributeStyleMap および has() で検索
const hasPadTop = buttonEl.attributeStyleMap.has('padding-top);

console.log(hasPadTop); // padding-top が style 属性にあれば true を記録

仕様書

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

ブラウザーの互換性

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
has

Legend

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

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