CSSStyleDeclaration item() Method
Example
Return the first CSS property name from the style declaration of the "ex1" element:
var style = document.getElementById("ex1").style;
var propname = style.item(0);
alert(propname);
Try it Yourself »
Definition and Usage
The item() method returns a CSS property name from a CSS declaration block, by index.
The index starts at 0.
Browser Support
Method | |||||
---|---|---|---|---|---|
item() | Yes | 9.0 | Yes | Yes | Yes |
Syntax
style.item(index)
Parameter Values
Parameter | Description |
---|---|
index | Required. A number representing the index of the CSS property |
Technical Details
DOM Version: | CSS Object Model |
---|---|
Return Value: | A String, representing the name of the property |
More Examples
Example
Loop through all the element's style declarations:
for (i = 0; i < elmnt.style.length; i++) {
txt +=
elmnt.style.item(i)
}
Try it Yourself »
❮ CSSStyleDeclaration Object