Attr

EventTargetNodejs.html.Attr (extern class)

This type represents a DOM element's attribute as an object. In most DOM methods, you will probably directly retrieve the attribute as a string (e.g., Element.getAttribute(), but certain functions (e.g., Element.getAttributeNode()) or means of iterating give Attr types.

Documentation Attr by Mozilla Contributors, licensed under CC-BY-SA 2.5.

See:

Instance Members

localName: String

A DOMString representing the local part of the qualified name of the attribute.


value: String

The attribute's value.


name: String

The attribute's name.


namespaceURI: String

A DOMString representing the namespace URI of the attribute, or null if there is no namespace.


prefix: String

A DOMString representing the namespace prefix of the attribute, or null if no prefix is specified.


specified: Bool

This property always returns true. Originally, it returned true if the attribute was explicitly specified in the source code or by a script, and false if its value came from the default one defined in the document's DTD.


ownerElement: Element

The element holding the attribute.

Note: DOM Level 4 removed this property. The assumption was that since you get an Attr object from an Element, you should already know the associated element.

As that doesn't hold true in cases like Attr objects being returned by Document.evaluate, the DOM Living Standard reintroduced the property.

Gecko outputs a deprecation note starting from Gecko 7.0 7.0. This note was removed again in Gecko 49.0 49.0.