HTML DOM attribute object
HTML DOM node
HTML DOM (Document Object Model) in, all nodes are:
- Document is a document node
- All HTML elements is an element node
- All HTML attributes are attribute nodes
- HTML elements inserted into the text as a text node
- Comments are comment nodes
Attr objects
In the HTML DOM, Attr object represents an HTML attribute.
HTML attributes always belong to HTML elements.
NamedNodeMap objects
In the HTML DOM, the NamedNodeMap object represents an unordered list of nodes.
We can be accessed via the NamedNodeMap node node name.
Browser Support
All major browsers support Attr objects and NamedNodeMap objects.
Property / Method | description |
---|---|
attr .isId | If the property is the ID type, isId property returns true, otherwise returns false. |
attr .name | Returns the name of the property |
attr .value | Sets or returns the property value |
attr .specified | If the property is specified returns true, false otherwise |
nodemap .getNamedItem () | Returns the specified attribute node from the node list. |
nodemap .item () | Returns the list of nodes in the node at the specified index number. |
nodemap .length | Returns the number of nodes in the node list. |
nodemap .removeNamedItem () | Removes the specified attribute node |
nodemap .setNamedItem () | Sets the specified attribute node (by name) |
DOM 4 Warning !!!
In the W3C DOM core, Attr (attribute) node object object inherits all the attributes and methods.
In DOM 4 of, Attr (attribute) object is no longer inherit from node object.
In the long code quality to consider, in the properties of the object you want to avoid using the node object properties and methods:
Property / Method | Avoid reason |
---|---|
attr .appendChild () | Property no children |
attr .attributes | Property is not property |
attr .baseURI | Alternative use document.baseURI |
attr .childNodes | Property no children |
attr .cloneNode () | Alternative use attr.value |
attr .firstChild | Property no children |
attr .hasAttributes () | Property is not property |
attr .hasChildNodes | Property no children |
attr .insertBefore () | Property no children |
attr .isEqualNode () | Pointless |
attr .isSameNode () | Pointless |
attr .isSupported () | Usually true |
attr .lastChild | Property no children |
attr .nextSibling | Property no siblings |
attr .nodeName | Use attr .name alternative |
attr .nodeType | Usually 2 (ATTRIBUTE-NODE) |
attr .nodeValue | Use attr .value alternative |
attr .normalize () | No specification properties |
attr .ownerDocument | Usually your HTML documents |
attr .ownerElement | HTML elements you use to access the property |
attr .parentNode | HTML elements you use to access the property |
attr .previousSibling | Property no siblings |
attr .removeChild | Property no children |
attr .replaceChild | Property no children |
attr .textContent | Useattr .valuealternative |