CSSStyleDeclaration getPropertyValue() 方法
定義和用法
getPropertyValue()
方法返回指定 CSS 屬性的值。
實例
返回 color 属性的值:
var declaration = document.styleSheets[0].cssRules[0].style;
var propvalue = declaration.getPropertyValue("color");
alert(propvalue);
亲自試試
Syntax
object.getPropertyValue(propertyname)
Parameter
Parameter |
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 |