Javascript Reference
Categories: attributes

javascript attributes Description

@March 15, 2008, 1:22 a.m.
attributes, NamedNodeMapFirefox/Netscape/NN 6 IE 5 Chrome/Safari/DOM 1  


The object returned by the attributes property of every W3C DOM element object is a collection (array) of references to Attr (a.k.a. attribute) objects. An attribute type of node always has a name associated with it, which opens the way for methods of the collection of such nodes to access them directly by name, rather than iterating through the array in search of a matching node name. In the W3C DOM structure, the abstract representation of this array of named nodes is called the NamedNodeMap object, which shares some properties and methods of the IE attributes object. Since both objects refer to the same parts of a document tree, they are treated here together. A couple of other W3C DOM collections are also of the NamedNodeMap variety, but your primary contact with the NamedNodeMap in HTML documents is as a collection of Attr objects. Collection members are sorted in source code order.


There are more direct ways to access an attribute of an element (such as the getAttribute( ) or getAttributeNode( ) methods of all elements). The property and methods shown here, however, assume that your script has been handed a collection of attributes independent of their host element, and your processing starts from that point.

Object Model Reference
Object-Specific Properties
Object-Specific Methods
getNamedItem( )getNamedItemNS( )item( )removeNamedItem( )
removeNamedItemNS( )setNamedItem( )setNamedItemNS( )
Object-Specific Event Handler Properties


Powered by Linode.