HTML DOM attributes Property
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





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