HTML DOM Attributes
The Attr Object
In the HTML DOM, anAttr object represents anHTML attribute.
An HTML attribute always belongs to anHTML element.
NamedNodeMap
ANamedNodeMap is an array-like unordered collection of an element's attributes.
In other words: a NamedNodeMap is a list ofAttr objects.
A NamedNodeMap has alength property that returns the number of nodes.
The nodes can be accessed by name or index numbers. The index starts at 0.
Attribute Properties
| Property | Description |
|---|---|
| isId | Deprecated |
| name | Returns an attribute's name |
| value | Sets or returns an attribute's value |
| specified | Returns true if the attribute is specified |
NamedNodeMap Properties and Methods
| Method | Description |
|---|---|
| getNamedItem() | Returns an attribute node (by name) from a NamedNodeMap |
| item() | Returns an attribute node (by index) from a NamedNodeMap |
| length | Returns the number of attributes in a NamedNodeMap |
| removeNamedItem() | Removes an attribute (node) |
| setNamedItem() | Sets an attribute (node) by name |

