CSSStyleDeclaration.getPropertyCSSValue()

已废弃
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

CSSStyleDeclaration.getPropertyCSSValue() 方法接口返回一个CSSValue 包含一个属性的CSS值。请注意,如果属性名称是速记属性,则返回null。

现在你应该使用 CSSStyleDeclaration.getPropertyValue()

语法

let value = style.getPropertyCSSValue(property);

参数

  • property is a DOMString representing the property name to be retrieved.

返回值

  • value is a CSSValue containing the CSS value for a property. If none exists, returns null.

示例

The following JavaScript code gets an object containing the computed RGB values of the color CSS property:

var style = window.getComputedStyle(elem, null);
var rgbObj = style.getPropertyCSSValue('color').getRGBColorValue();

规范

Specification Status Comment
Document Object Model (DOM) Level 2 Style Specification
CSSStyleDeclaration
Obsolete Declared as obsolete in July 2003.

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
getPropertyCSSValue
Deprecated
Chrome No support ? — 41
Notes
No support ? — 41
Notes
Notes See bug 331608.
Edge No support No
Notes
No support No
Notes
Notes See bug 331608.
Firefox No support 1 — 62
Notes
No support 1 — 62
Notes
Notes Only returns a result if called on the result of getComputedStyle().
IE No support NoOpera No support 15 — 28
Notes
No support 15 — 28
Notes
Notes See bug 331608.
Safari Full support 6WebView Android No support ? — 41
Notes
No support ? — 41
Notes
Notes See bug 331608.
Chrome Android No support ? — 41
Notes
No support ? — 41
Notes
Notes See bug 331608.
Firefox Android No support 4 — 62Opera Android No support 14 — 28
Notes
No support 14 — 28
Notes
Notes See bug 331608.
Safari iOS Full support YesSamsung Internet Android No support ? — 4.0
Notes
No support ? — 4.0
Notes
Notes See bug 331608.

Legend

Full support  
Full support
No support  
No support
Deprecated. Not for use in new websites.
Deprecated. Not for use in new websites.
See implementation notes.
See implementation notes.