CSSStyleDeclaration.getPropertyPriority()
method interface returns a
DOMString
that provides all explicitly set priorities on the CSS property.
var priority = style.getPropertyPriority(property);
property
是
DOMString
representing the property name to be checked.
priority
是
DOMString
that represents the priority (e.g.
"important"
) if one exists. If none exists, returns the empty string.
The following JavaScript code checks whether
margin
is marked as important in a CSS selector rule:
var declaration = document.styleSheets[0].cssRules[0].style;
var isImportant = declaration.getPropertyPriority('margin') === 'important';
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
getPropertyPriority
|
Chrome 1 | Edge 12 | Firefox 1 | IE Yes | Opera Yes | Safari 6 | WebView Android 4.4 | Chrome Android 18 | Firefox Android 4 | Opera Android Yes | Safari iOS Yes | Samsung Internet Android 1.0 |
完整支持
CSSStyleDeclaration
getPropertyCSSValue()
getPropertyPriority()
getPropertyValue()
item()
removeProperty()
setProperty()
AnimationEvent
CSS
CSSConditionRule
CSSGroupingRule
CSSKeyframeRule
CSSKeyframesRule
CSSMediaRule
CSSNamespaceRule
CSSPageRule
CSSRule
CSSRuleList
CSSStyleRule
CSSStyleSheet
CSSSupportsRule
CaretPosition
LinkStyle
MediaQueryList
MediaQueryListListener
Screen
StyleSheet
StyleSheetList
TransitionEvent