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 check. |
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 |