HTML DOM lengthProperty

属性对象参考手册Property Object

Example

Return the number of attributes of the button element:

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

Output:

1

Try it Yourself »

Definition and Usage

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


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the length property.

Note:In 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: A number, representing the number of nodes.
DOM Version Core Level 1


属性对象参考手册Property Object

Other Extensions