Attr : Node
Return to: HTML DOM Level 2 index

Represents the attributes of an Element object.

Constructors

Constructor Action IE Mozilla Netscape Opera Safari Chrome
Represents the attributes of an Element object.
Show Details

Attr() : Attr

Represents the attributes of an Element object.

Returns
Attr

Visibility
internal

Properties

Property Action IE Mozilla Netscape Opera Safari Chrome
name : String
Name of the attribute object.
Show Details 4.0+ 1.0+ 6.0+ 7.0+ 1.0+ no

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/attributes.html

Remarks
Due to the nature of DOM Element attributes, the name value must be unique across attributes attached to the same element node.
Availability

W3C|HTML DOM Level 2

ownerElement : Element
Parent node that the attribute is attached to.
Show Details 4.0+ 1.0+ 6.0+ 7.0+ 1.0+ no
Remarks
Because attributes are meaningless unless they are bound to an Element, this property allows you to find the node that an attribute is attached to. If this attribute is not yet attached to a node, the value of this property is set to null.
Availability

W3C|HTML DOM Level 2

specified : Boolean
If true, specifies that the attribute was explicitly created.
Show Details 4.0+ 1.0+ 6.0+ 7.0+ 1.0+ no

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/attributes.html

Remarks

If true, indicates that this attribute value was explicitly set from a source XML document or via a DOM method call. Otherwise, the specified property is false.

For example, if a document has an element definition with a "width" attribute with a default value of "3", the specified property for the Attr of the element is set to false when the document loads. If the value of the is subsequently changed, this property will change to true. You can only revert the specified property back to its original value by deleting the attribute from its parent node so that the DTD recreates the default attribute.

Availability

W3C|HTML DOM Level 2

value : String
Value of the attribute.
Show Details 4.0+ 1.0+ 6.0+ 7.0+ 1.0+ no

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/attributes.html

Remarks

Returns and sets the value of the attribute as a String. Replaces entity references with their values. In addition to methods for retrieving Attr objects, the Element object has methods for accessing the value of an attribute without having to deal directly with the Attr object.

Availability

W3C|HTML DOM Level 2

Remarks

Attributes are properties of Elements and do not have their own identities. Although an Attr is a descendant of a Node, an Attr is not placed in a parentNode, nextSibling or previousSibling, and its own instances of those properties are null. Additionally, an Attr objects may only be a child of an Element object.

Set the value of an attribute either via the DOM, from a source document, or from a DTD or other XML Schema. If a declaration for an attribute exists that defines a default value, and the attribute in question does not exist, the attribute will be automatically added with the given value. Usually, however, an attribute does not exist until it is explicitly added.

References

Element

Availability

HTML DOM Level 2|W3C

text_javascript aptana_docs