CSSStyleDeclaration getPropertyValue() 方法
定义和用法
getPropertyValue()
方法返回指定 CSS 属性的值。
实例
返回 color 属性的值:
var declaration = document.styleSheets[0].cssRules[0].style;
var propvalue = declaration.getPropertyValue("color");
alert(propvalue);
试一试亲自
Syntax
object.getPropertyValue(propertyname)
Parameters
Parameters |
Description |
propertyname |
Required. String, representing the name of the attribute to be checked. |
Technical details
DOM version: |
CSS Object Model |
Return value: |
String, representing the value of the attribute. |
Browser support
Chrome |
Edge |
Firefox |
Safari |
Opera |
Chrome |
Edge |
Firefox |
Safari |
Opera |
Support |
9.0 |
Support |
Support |
Support |