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

HTML DOM length Property

HTML DOM length Property

Attribute Object Reference Attribute object

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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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 Reference Attribute object