HTML DOM length Property
Example
Return the number of attributes of the button element:
document.getElementsByTagName("BUTTON")[0].attributes.length;
Output result:
1
Try it »
Definition and Usage
The length property returns the number of nodes in a collection.
Browser support





All major browsers support the length property.
Note: Internet Explorer 8 and earlier IE versions, the length property returns the number of all possible attributes of an element.
Syntax
namednodemap
.length
Technical Details
| Return Value: | Number, representing the number of nodes. |
|---|---|
| DOM version | Core Level 1 |
Attribute object