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

HTML DOM attributes Property

HTML DOM attributes Property

Element Object Reference Element object

Example

Get the collection of element attributes:

document

.

getElementsByTagName

(

"

BUTTON

"

)

[

0

]

.

attributes

;

Try it »


Definition and Usage

The attributes property returns a collection of the specified node's attributes.

**Tip:** You can use the length property to determine the number of attributes, then you can iterate through all attribute nodes to extract the information you want.

**Tip:** Each attribute is an available attribute node object.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the attributes property

Note: In Internet Explorer 8 and earlier versions, the attributes property returns a collection of all possible attributes of the element.


Syntax

node

.attributes

Technical Details

Return Value: NamedNodeMap object, representing a collection of attributes.
DOM version Core Level 1 Node Object

Element Object Reference Element object