CSSStyleDeclaration.getPropertyPriority()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2015.
CSSStyleDeclaration.getPropertyPriority() メソッドインターフェイスは、その CSS プロパティに明示的に設定されたすべての優先度を文字列で返します。
構文
js
getPropertyPriority(property)
引数
property
-
文字列で、チェックするプロパティ名を表します。
返値
存在する場合は優先度("important"
など)を表します。
存在しない場合は、空文字列を返します。
例
以下の JavaScript コードは、 margin
が CSS セレクターのルールで important と記されているかどうかをチェックします。
js
const declaration = document.styleSheets[0].cssRules[0].style;
const isImportant = declaration.getPropertyPriority("margin") === "important";
仕様書
Specification |
---|
CSS Object Model (CSSOM) # dom-cssstyledeclaration-getpropertypriority |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
getPropertyPriority |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.