--- title: Attr slug: Web/API/Attr translation_of: Web/API/Attr ---
Este tipo representa un atributo de un elemento DOM como un objeto. En muchos métodos DOM, probablemente vas a obtener el atributo como una cadena (e.g., {{domxref("Element.getAttribute()")}}, pero algunas funciones (e.g., {{domxref("Element.getAttributeNode()")}}) or means of iterating give Attr
types.
{{InheritanceDiagram}}
Attr
se hereda del {{domxref("Node")}}. Este ya no es el caso en DOM4.Para llevar la implementación de Attr a la especifiación, se esta trabajando para cambiarlo y dejar de heredar de{{domxref("Node")}}. No debe de utilizar ninguna propiedad o método de nodo en los objetos Attr
. A partir de Gecko 7.0 (Firefox 7.0 / Thunderbird 7.0 / SeaMonkey 2.4), los que se eliminarán enviarán mensajes de advertencia a la consola. Debe revisar su código en consecuencia. Consulte Propiedades y métodos en desuso para obtener una lista completa.null
if there is no namespace.null
if no prefix is specified.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.Note: DOM Level 3 defined namespaceURI
, localName
and prefix
on the {{domxref("Node")}} interface. In DOM4 they were moved to Attr
.
This change is implemented in Chrome since version 46.0 and Firefox since version 48.0.
Las siguientes propiedades son obsoletos. Where available, the appropriate replacement is provided.
attributes
NULL
.childNodes
NULL
.firstChild
NULL
.isId
{{readOnlyInline}}lastChild
NULL
.nextSibling
NULL
.nodeName
nodeType
ATTRIBUTE_NODE
).nodeValue
ownerDocument
ownerElement
{{deprecated_inline("7.0")}} {{obsolete_inline("29.0")}} {{readOnlyInline}}Attr
object from an {{domxref("Element")}}, you should already know the associated element.Attr
objects from an XPath, in which case you would not easily know the owner.parentNode
NULL
.previousSibling
NULL
.schemaTypeInfo
{{obsolete_inline}} {{readOnlyInline}}specified
true
.textContent
Los siguientes metodos ahora son obsoletos.
appendChild()
cloneNode()
createAttribute()
createAttributeNS()
getAttributeNode()
getAttributeNodeNS()
hasAttributes()
{{obsolete_inline("21.0")}}hasChildNodes()
false
.insertBefore()
isSupported()
isEqualNode()
normalize()
removeAttributeNode()
removeChild()
replaceChild()
setAttributeNode()
setAttributeNodeNS()
Especificación | Estado | Comentario |
---|---|---|
{{SpecName("DOM4", "#interface-attr", "Attr")}} | {{Spec2("DOM4")}} | Moved namespaceURI , prefix and localName from {{domxref("Node")}} to this API and removed ownerElement , schemaTypeInfo and isId . |
{{SpecName("DOM3 Core", "core.html#ID-637646024", "Attr")}} | {{Spec2("DOM3 Core")}} | Definición inicial |
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}}[1] | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |
Feature | Android | Android Webview | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} [1] | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}}[1] |
[1] As of Chrome 45, this property no longer inherits from Node.