HTML DOM Attributes


The Attr Object

In the HTML DOM, an Attr object represents an HTML attribute.

An HTML attribute always belongs to an HTML element.


NamedNodeMap

A NamedNodeMap is an array-like unordered collection of an element's attributes.

In other words: a NamedNodeMap is a list of Attr objects.

A NamedNodeMap has a length 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

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.