You are here: Reference > JavaScript > client-side > style handling > methods > item (currentStyle, style, ...)

item method (currentStyle, style, ...)

Browser support:
Returns the name of the property that is located at the specified position in the current style object.
Note: The item method is supported in Internet Explorer from version 9.
The order of properties is browser dependent. This method is useful if you want to iterate over the properties of a style object.
The number of properties can be retrieved with the length property.
The name of a style property can be used for the getPropertyValue, removeProperty and setProperty methods.


object.item (index);
You can find the related objects in the Supported by objects section below.


Required. Zero-based integer that specifies the index of the style property.

Return value:

String. The name of the style property.

Example HTML code 1:

This example illustrates the use of the item method:
    <script type="text/javascript">
        function IterateStyles (button) {
            for (i = 0; i <; i++) {
                var propName = (i);
                var value = (propName);
                alert (propName + " = " + value);
    <button onclick="IterateStyles (this)" style="margin:10px;">Iterate styles</button>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content