Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

CSSStyleDeclaration item() method

CSSStyleDeclaration item() method

CSS CSSStyleDeclaration CSS CSSStyleDeclaration

Example

Returns the first property name of the style corresponding to the element with id ex1:

var

style

=

document

.

getElementById

(

"

ex1

"

)

.

style

;

var

propname

=

style

.

item

(

0

)

;

alert

(

propname

)

;

Try it »


Definition and usage

The item() method returns the property name at the specified index position in the CSS style; the index starts from 0.


Browser support

Method
item() Yes 9.0 Yes Yes Yes

Syntax



style.item(index)


Attribute values

Parameters Description
index Required. A number representing the index position of the CSS style property.

Technical Details

DOM version: CSS Object Model
Return value: A string representing the property name.

More examples

Example

Loop through and output all the style property names of the element:

for

(

i

=

0

;

i

<

elmnt

.

style

.

length

;

i

++

)

{

txt

+=

elmnt

.

style

.

item

(

i

)

}

Try it »

CSS CSSStyleDeclaration CSS CSSStyleDeclaration