CSSStyleDeclaration.getPropertyCSSValue()

已弃用: 不再推荐使用该特性。虽然一些浏览器仍然支持它,但也许已从相关的 web 标准中移除,也许正准备移除或出于兼容性而保留。请尽量不要使用该特性,并更新现有的代码;参见本页面底部的兼容性表格以指导你作出决定。请注意,该特性随时可能无法正常工作。

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:

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

规范

该特性最初在 DOM Style Level 2 中定义,但从那时起已从标准化工作中移除。

它已被现代、不兼容的 CSS 类型对象模型 API 取代,该 API 已被标准化。

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
getPropertyCSSValue
Deprecated

Legend

Tip: you can click/tap on a cell for more information.

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