English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
-
1 var output = document.getElementById("result"); function myFunc1() { var styleObj = heading.style; output.innerHTML = styleObj.cssText; } function myFunc2() { var prop = window.getComputedStyle(heading, null).getPropertyValue("color"); output.innerHTML = prop; }Test and see‹/›
HTMLElement.styleHandle the inline styles of a single element.
window.getComputedStyle()Expose the CSSStyleDeclaration object as a read-only interface.
The following table lists the properties of the CSSStyleDeclaration object:
Property | Description |
---|---|
cssText | Set or return the text representation of the CSS declaration block |
length | Return the number of style declarations in the CSS declaration block |
parentRule | Return the CSS rule that is the parent of the style block |
The following table lists the methods of the CSSStyleDeclaration object:
Method | Description |
---|---|
getPropertyPriority() | Return whether the specified CSS property has an 'important' rule set |
getPropertyValue() | Return the value of the specified CSS property |
item() | Return CSS property names from the CSS declaration block by index |
removeProperty() | Remove CSS properties from the CSS declaration block |
setProperty() | Set new or modify existing CSS properties in the CSS declaration block |