X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

HTML DOM length Property

Attribute Object Reference Attribute Object

Example

Return the number of attributes of a button element:

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

The result could be:

1

Try it yourself »


Definition and Usage

The length property return the number of nodes in a collection.

A Node object's attributes is an example of a NamedNodeMap object.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The length property is supported in all major browsers.

Note: In Internet Explorer 8 and earlier, the length property for attributes will return the number of all possible attributes for an element.


Syntax

namednodemap.length

Technical Details

Return Value: A Number, representing the number of nodes in the nodemap
DOM Version Core Level 1


Attribute Object Reference Attribute Object


Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook