CSSStyleDeclaration item() Method
Definition and Usage
item()
The method returns the CSS property name by index (subscript) from the CSS declaration block.
The index starts from 0.
Instance
Example 1
Return the first CSS property name from the style declarations of the "ex1" element:
var style = document.getElementById("ex1").style; var propname = style.item(0); alert(propname);
Example 2
Loop through all element style declarations:
for (i = 0; i < elmnt.style.length; i++) { txt += elmnt.style.item(i) }
Syntax
style.item(index)
Parameter
Parameter | Description |
---|---|
index | Required. Number, representing the index (subscript) of the CSS property. |
Technical Details
DOM Version: | CSS Object Model |
---|---|
Return value: | String representing the name of the attribute. |
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | 9.0 | Support | Support | Support |