Latest web development tutorials

HTML DOM length property

Property Object Reference Attribute object

Examples

Properties button returns the number of elements:

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

Output:

1

try it"

Definition and Usage

The length property returns the number of options in the collection of nodes.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support length property

Note: Internet Explorer 8 and earlier versions of IE, length property returns the number of all possible elements of a property.


grammar

namednodemap .length

technical details

return value: Number represents the number of nodes.
DOM version Core Level 1


Property Object Reference Attribute object