HTML DOM attributesProperty

元素对象参考手册Element Object

Example

Get the collection of element attributes:

document.getElementsByTagName("BUTTON")[0].attributes;

Try it Yourself »

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, and then you can loop through all the attribute nodes to extract the information you want.

Tip:Each attribute is an 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: A NamedNodeMap object, representing a collection of attributes.
DOM Version Core Level 1 Node Object


元素对象参考手册Element Object

Other Extensions