CSSStyleDeclaration.getPropertyValue()
method interface returns a
DOMString
containing the value of a specified CSS property.
var value = style.getPropertyValue(property);
property
是
DOMString
representing the property name to be checked.
value
是
DOMString
containing the value of the property. If not set, returns the empty string.
The following JavaScript code queries the value of the
margin
property in a CSS selector rule:
var declaration = document.styleSheets[0].cssRules[0].style;
var value = declaration.getPropertyValue('margin'); // "1px 2px"
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
getPropertyValue
|
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