English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSSStyleDeclaration getPropertyPriority() メソッド

 JavaScript CSSStyleDeclaration オブジェクト

getPropertyPriority()方法は、指定されたCSS属性が「!important」優先度を設定しているかどうかを返します。

「important」が返された場合、優先度が設定されていることを示します。それ以外の場合、設定されていません。

文法:

object.getPropertyPriority(property)
var declaration = document.styleSheets[0].rules[0].style;
var isImportant = declaration.getPropertyPriority('color');
document.getElementById("result").innerHTML = isImportant;
テストをしてみる‹/›

ブラウザの互換性

getPropertyPriority()メソッドはすべてのブラウザで完全にサポートされています:

メソッド
getPropertyPriority()

引数の値

引数説明
property要検証する属性の名前を示す文字列

技術的詳細

返り値:優先順位を示す文字列、存在しない場合は空文字列
DOMバージョン:CSSオブジェクトモデル

 JavaScript CSSStyleDeclaration オブジェクト