Revision Content

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., {{ domxref("Element.getAttribute()") }}, but certain functions (e.g., {{ domxref("Element.getAttributeNode()") }}) or means of iterating give Attr types. Also inherits the {{ domxref("Node") }} methods and properties.

Warning: In order to bring the implementation of Attr up to specification, work is underway to change it to no longer inherit from {{ domxref("Node") }}. You should not be using any {{ domxref("Node") }} properties or methods on Attr objects. Starting in Gecko 7.0 {{ geckoRelease("7.0") }}, the ones that are going to be removed output warning messages to the console. You should revise your code accordingly. See {{ anch("Deprecated properties and methods") }} for a complete list.