Packagedom.core
Classpublic class Attr
InheritanceAttr Inheritance Node Inheritance Object

Introduced in: DOM 1 Core 
Modified in: DOM 3 Core 

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., getAttribute), but certain functions (e.g., getAttributeNode()) or means of iterating give Attr types.

See also

MSDN - Attr Prototype
MDC - Attr
W3C - Attr


Public Properties
 PropertyDefined By
 InheritedDOM 1 Core attributes : NamedNodeMap
[read-only] Returns an unordered collection of Attr nodes.
Node
 InheritedNon-Standard baseName : DOMString
[read-only] Returns the base name for the name qualified with the namespace.
Node
 InheritedDOM 3 Core baseURI : DOMString
[read-only] The absolute base URI of this node or null if the implementation wasn't able to obtain an absolute URI.
Node
 InheritedDOM 1 Core childNodes : NodeList
[read-only] Returns an ordered collection of node objects that are children of the current element.
Node
 InheritedNon-Standard dataType : *
Specifies the data type for this node.
Node
 InheritedNon-Standard definition : Node
[read-only] Returns the definition of the node in the document type definition (DTD) or schema.
Node
  Non-Standard expando : Boolean
Sets or retrieves a value indicating whether arbitrary variables can be created within the object.
Attr
 InheritedDOM 1 Core firstChild : Node
[read-only] Returns the node's first child in the tree, or null if the node is childless.
Node
  DOM 3 Core isId : Boolean
[read-only] Returns whether this attribute is known to be of type ID (i.e.
Attr
 InheritedDOM 1 Core lastChild : Node
[read-only] Returns the last child of a node.
Node
 InheritedDOM 2 Core localName : DOMString
[read-only] Returns the local part of the qualified name of this node.
Node
  DOM 1 Core name : DOMString
[read-only] Returns the name of this attribute.
Attr
 InheritedDOM 2 Core namespaceURI : DOMString
[read-only] The namespace URI of the node, or null if it is unspecified (read-only).
Node
 InheritedDOM 1 Core nextSibling : Node
[read-only] Returns the node immediately following the specified one in its parent's childNodes list, or null if the specified node is the last node in that list.
Node
 InheritedDOM 1 Core nodeName : DOMString
[read-only] Returns the name of the current node as a string.
Node
 InheritedNon-Standard nodePrincipal : nsIPrincipal
[read-only] Returns the nsIPrincipal object representing current security context of the node.
Node
 InheritedDOM 1 Core nodeType : Number
[read-only] Returns an integer code representing the type of the node.
Node
 InheritedNon-Standard nodeTypedValue : *
Contains the node value expressed in its defined data type.
Node
 InheritedNon-Standard nodeTypeString : DOMString
[read-only] Returns the node type in string form.
Node
 InheritedDOM 1 Core nodeValue : DOMString
Returns or sets the value of the current node.
Node
 InheritedDOM 1 Core ownerDocument : Document
[read-only] The Document object associated with this node.
Node
  DOM 2 Core ownerElement : Element
[read-only] The Element node this attribute is attached to or null if this attribute is not in use.
Attr
 InheritedDOM 1 Core parentNode : Node
[read-only] Returns the parent of the specified node in the DOM tree.
Node
 InheritedNon-Standard parsed : Boolean
[read-only] Indicates the parsed status of the node and child nodes.
Node
 InheritedDOM 2 Core prefix : DOMString
Returns the namespace prefix of the specified node, or null if no prefix is specified.
Node
 InheritedDOM 1 Core previousSibling : Node
[read-only] Returns the node immediately preceding the specified one in its parent's childNodes list, null if the specified node is the first in that list.
Node
  DOM 3 Core schemeTypeInfo : TypeInfo
[read-only] The type information associated with this attribute.
Attr
  DOM 1 Core specified : Boolean
[override] [read-only] True if this attribute was explicitly given a value in the instance document, false otherwise.
Attr
 InheritedNon-Standard text : DOMString
Represents the text content of the node or the concatenated text representing the node and its descendants.
Node
 InheritedDOM 3 Core textContent : DOMString
Gets or sets the text content of a node and its descendants.
Node
  DOM 1 Core value : DOMString
On retrieval, the value of the attribute is returned as a string.
Attr
 InheritedNon-Standard xml : DOMString
[read-only] Contains the XML representation of the node and all its descendants.
Node
Public Methods
 MethodDefined By
 Inherited
DOM 2 Events addEventListener(type:DOMString, listener:EventListener, useCapture:Boolean):void
Associates a function with a particular event and binds the event to the current node.
Node
 Inherited
DOM 3 Events addEventListenerNS(namespaceURI:DOMString, type:DOMString, listener:EventListener, useCapture:Boolean):void
Registers an event listener, depending on the useCapture parameter, on the capture phase of the DOM event flow or its target and bubbling phases.
Node
 Inherited
DOM 1 Core appendChild(element:Node):Node
Adds a node to the end of the list of children of a specified parent node.
Node
 Inherited
DOM 1 Core cloneNode(cloneChildren:Boolean):Node
Returns a duplicate of the current node.
Node
 Inherited
DOM 3 Core compareDocumentPosition(other:Node):Number
Compares the position of the current node against another node in any other document.
Node
 Inherited
DOM 2 Events dispatchEvent(evt:Event):Boolean
Dispatches an event to fire on a node artificially.
Node
 Inherited
DOM 3 Core getFeature(feature:DOMString, version:DOMString):DOMObject
This method returns a specialized object which implements the specialized APIs of the specified feature and version, as specified in DOM Features.
Node
 Inherited
Retrieves the object associated to a key on a this node.
Node
 Inherited
DOM 2 Core hasAttributes():Boolean
Returns a boolean value of true or false, indicating if the current element has any attributes or not.
Node
 Inherited
DOM 1 Core hasChildNodes():Boolean
Returns a value that indicates whether the object has children.
Node
 Inherited
DOM 1 Core insertBefore(newNode:Node, childNode:Node):Node
Inserts the specified node before a reference element as a child of the current node.
Node
 Inherited
DOM 3 Core isDefaultNamespace(namespaceURI:DOMString):Boolean
Returns true if the namespace is the default namespace on the given node or false if not.
Node
 Inherited
DOM 3 Core isEqualNode(arg:Node):Boolean
Tests whether two nodes are equal.
Node
 Inherited
DOM 3 Core isSameNode(other:Node):Boolean
Returns whether this node is the same node as the given one.
Node
 Inherited
DOM 2 Core isSupported(feature:DOMString, version:DOMString):Boolean
Tests whether the DOM implementation implements a specific feature and that feature is supported by this node.
Node
 Inherited
Takes a prefix and returns the namespaceURI associated with it on the given node if found (and null if not).
Node
 Inherited
DOM 3 Core lookupPrefix(namespaceURI:DOMString):DOMString
Returns the prefix for a given namespaceURI if present, and null if not.
Node
 Inherited
DOM 1 Core normalize():void
Puts the specified node and all of its subtree into a "normalized" form.
Node
 Inherited
DOM 1 Core removeChild(node:Node):Node
Removes a child node from the object.
Node
 Inherited
DOM 2 Events removeEventListener(type:DOMString, listener:EventListener, useCapture:Boolean):void
Removes an event listener.
Node
 Inherited
DOM 3 Events removeEventListenerNS(namespaceURI:DOMString, type:DOMString, listener:EventListener, useCapture:Boolean):void
Removes an event listener.
Node
 Inherited
DOM 1 Core replaceChild(newNode:Node, childNode:Node):Node
Replaces an existing child element with a new child element.
Node
 Inherited
Non-Standard selectNodes(queryString:DOMString):NodeList
Applies the specified pattern-matching operation to this node's context and returns the list of matching nodes as IXMLDOMNodeList.
Node
 Inherited
Non-Standard selectSingleNode(queryString:DOMString):Node
Applies the specified pattern-matching operation to this node's context and returns the first matching node.
Node
 Inherited
Associate an object to a key on this node.
Node
 Inherited
Non-Standard transformNode(styleSheet:Node):DOMString
Processes this node and its children using the supplied Extensible Stylesheet Language Transformations (XSLT) style sheet and returns the resulting transformation.
Node
 Inherited
Non-Standard transformNodeToObject(styleSheet:Node, outputObject:*):void
Processes this node and its children using the supplied Extensible Stylesheet Language Transformations (XSLT) style sheet and returns the resulting transformation.
Node
Events
 Event Summary Defined By
  A node has been added as a child of another node or, in case of Attr nodes, has been added to an Element.Attr
  A node has been inserted into a document, either through direct insertion of the node or insertion of a subtree in which it is contained; Attr nodes are considered part of an Element's subtree.Attr
  A node is being removed from its parent node or, in case of Attr nodes, removed from its ownerElement.Attr
  A node is being removed from a document, either through direct removal of the node or removal of a subtree in which it is contained; Attr nodes are considered part of an Element's subtree.Attr
  This is a general event for notification of all changes to the document.Attr
Public Constants
 ConstantDefined By
 InheritedDOM 1 Core ATTRIBUTE_NODE : Number = 2
[static] The node is an Attr.
Node
 InheritedDOM 1 Core CDATA_SECTION_NODE : Number = 4
[static] The node is a CDATASection.
Node
 InheritedDOM 1 Core COMMENT_NODE : Number = 8
[static] The node is a Comment.
Node
 InheritedDOM 1 Core DOCUMENT_FRAGMENT_NODE : Number = 11
[static] The node is a DocumentFragment.
Node
 InheritedDOM 1 Core DOCUMENT_NODE : Number = 9
[static] The node is a Document.
Node
 InheritedDOM 3 Core DOCUMENT_POSITION_CONTAINED_BY : Number = 16
[static] The node is contained by the reference node.
Node
 InheritedDOM 3 Core DOCUMENT_POSITION_CONTAINS : Number = 8
[static] The node contains the reference node.
Node
 InheritedDOM 3 Core DOCUMENT_POSITION_DISCONNECTED : Number = 1
[static] The two nodes are disconnected.
Node
 InheritedDOM 3 Core DOCUMENT_POSITION_FOLLOWING : Number = 4
[static] The node follows the reference node.
Node
 InheritedDOM 3 Core DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC : Number = 32
[static] The determination of preceding versus following is implementation-specific.
Node
 InheritedDOM 3 Core DOCUMENT_POSITION_PRECEDING : Number = 2
[static] The second node precedes the reference node.
Node
 InheritedDOM 1 Core DOCUMENT_TYPE_NODE : Number = 10
[static] The node is a DocumentType.
Node
 InheritedDOM 1 Core ELEMENT_NODE : Number = 1
[static] The node is an Element.
Node
 InheritedDOM 1 Core ENTITY_NODE : Number = 6
[static] The node is an Entity.
Node
 InheritedDOM 1 Core ENTITY_REFERENCE_NODE : Number = 5
[static] The node is an EntityReference.
Node
 InheritedDOM 1 Core NOTATION_NODE : Number = 12
[static] The node is a Notation.
Node
 InheritedDOM 1 Core PROCESSING_INSTRUCTION_NODE : Number = 7
[static] The node is a ProcessingInstruction.
Node
 InheritedDOM 1 Core TEXT_NODE : Number = 3
[static] The node is a Text node.
Node
Property Detail
expandoproperty
expando:Boolean

Product Versions : Internet Explorer 5.5 Internet Explorer 6.0 Internet Explorer 7.0 Internet Explorer 8.0 as IE7 Internet Explorer 8.0 as IE8 Firefox 2.0 Firefox 3.0 Firefox 3.5 Safari 3.0 Safari 3.1 Safari 4.0b Chrome 1.0 Chrome 2.0 Opera 9.62 Opera 10.0a

Non-standard (Microsoft)

Sets or retrieves a value indicating whether arbitrary variables can be created within the object.

Note: You can extend the properties on an object by creating arbitrary properties with values. You should be careful, however, because you can unintentionally set a property value when scripting in a case-sensitive language such as Microsoft JScript. For example, if the property value is borderColor and you type the value "bordercolor = 'blue'", you have, in fact, created another property on the style object called bordercolor with the value 'blue'. If you query the value of the property, the value "blue" is returned. However, the borders for the element do not turn blue.

Note: Setting the expando property of the document object to false precludes the functionality of all expandos within the document.

The default value is true.


Implementation
    public function get expando():Boolean
    public function set expando(value:Boolean):void

See also


Example
The following example demonstrates that, by setting the expando property of the document object to false, the document ignores the UNSELECTABLE expando on the span and allows you to select the text.
         <html>
         
         <head>
         <script type="text/javascript">
             //Set the expando property to false.
             document.expando = false;
         </script>
         </head>
         
         <body>
         
         <div>
         <span id="oSpan" unselectable="on">This text should be selectable.</span>
         </div>
         
         </body>
         
         </html>
DOM 3 Core isIdproperty 
isId:Boolean  [read-only]

Introduced in: DOM 3 Core 

Returns whether this attribute is known to be of type ID (i.e. to contain an identifier for its owner element) or not.

When it is and its value is unique, the ownerElement of this attribute can be retrieved using the method Document.getElementById.


Implementation
    public function get isId():Boolean

See also

DOM 1 Core nameproperty 
name:DOMString  [read-only]

Introduced in: DOM 1 Core 

Returns the name of this attribute. If Node.localName is different from null, this attribute is a qualified name.

Note (IE8): Internet Explorer 8 and later. In IE8 mode, dynamically setting the name attribute on an input type=radio button correctly applies that button to the same named group.

Note (IE): When submitting a form, use the name property to bind the value of the control. The name is not the value displayed for the input type=button, input type=reset, and input type=submit input types. The internally stored value is submitted with the form, not the displayed value.

Note (IE): Microsoft JScript allows the name to be changed at run time. This does not cause the name in the programming model to change in the collection of elements, but it does change the name used for submitting elements.

Note (IE8): Internet Explorer 8 and later can set the NAME attribute at run time on elements dynamically created with the createElement method. To create an element with a NAME attribute in earlier versions of Internet Explorer, include the attribute and its value when using the createElement method.


Implementation
    public function get name():DOMString

See also


Example
         var inp = document.createElement('input');
         inp.setAttribute('type',  'radio');
         inp.setAttribute('name',  'Q'+count);
         inp.setAttribute('value', answers[i]);
DOM 2 Core ownerElementproperty 
ownerElement:Element  [read-only]

Introduced in: DOM 2 Core 

The Element node this attribute is attached to or null if this attribute is not in use.

Note (IE8): This property is new as of Internet Explorer 8.


Implementation
    public function get ownerElement():Element

See also

DOM 3 Core schemeTypeInfoproperty 
schemeTypeInfo:TypeInfo  [read-only]

Introduced in: DOM 3 Core 

The type information associated with this attribute.

While the type information contained in this attribute is guarantee to be correct after loading the document or invoking Document.normalizeDocument(), schemaTypeInfo may not be reliable if the node was moved.


Implementation
    public function get schemeTypeInfo():TypeInfo

See also

DOM 1 Core specifiedproperty 
specified:Boolean  [read-only] [override]

Introduced in: DOM 1 Core 

True if this attribute was explicitly given a value in the instance document, false otherwise.

If the application changed the value of this attribute node (even if it ends up having the same value as the default value) then it is set to true. The implementation may handle attributes with default values from other schemas similarly but applications should use Document.normalizeDocument() to guarantee this information is up-to-date.


Implementation
    public function get specified():Boolean

See also


Example
his example uses the specified property to determine the attributes set for an object. The function checks each attribute, and lists all of the attributes of the object and the value of each attribute. In addition, each attribute that is set is displayed.
         <script>
         function fnFindSpecified(){
             var oAttributes=oList.attributes;
             alert(oAttributes(0).nodeName);
             for(var i=0;i<oAttributes.length;i++){
                 var oNode=document.createElement("LI");
                 var oNodeValue=document.createTextNode(i + " "
                     + oAttributes(i).nodeName + " = "
                     + oAttributes(i).nodeValue);
                 oList.appendChild(oNode);
                 oNode.appendChild(oNodeValue);
                 if(oAttributes(i).nodeValue!=null){
                     alert(oAttributes(i).nodeName
                     + " specified: " + oAttributes(i).specified);
                 }
             }
         }
         </script>
         
         <ul id=oList onclick="fnFindSpecified()">
         <li>Click to Find Specified Attributes</li>
         </ul>
DOM 1 Core valueproperty 
value:DOMString

Introduced in: DOM 1 Core 

On retrieval, the value of the attribute is returned as a string. Character and general entity references are replaced with their values.

On setting, this creates a Text node with the unparsed contents of the string, i.e. any characters that an XML processor would recognize as markup are instead treated as literal text.

Note (IE8): Internet Explorer 8 or later. In IE8 mode, the value property is correctly reported as a canonical attribute name. For example, <input type="text" readonly> and <input type="text" readonly="readonly"> would both set the input text field to read-only. In IE8 mode, the value is evaluated as a cannonical value, "readonly". In earlier document compatibility modes, it is evaluated as a Boolean value, true.


Implementation
    public function get value():DOMString
    public function set value(value:DOMString):void

Throws
DOMException — NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.

See also

Event Detail
DOMNodeInserted Event
Event Object Type: dom.events.MutationEvent
MutationEvent.type property = DOMNodeInserted

A node has been added as a child of another node or, in case of Attr nodes, has been added to an Element. This event is dispatched after the insertion has taken place. The target node of this event is the node being inserted.

DOMNodeInsertedIntoDocument Event  
Event Object Type: dom.events.MutationEvent
MutationEvent.type property = DOMNodeInsertedIntoDocument

A node has been inserted into a document, either through direct insertion of the node or insertion of a subtree in which it is contained; Attr nodes are considered part of an Element's subtree. This event is dispatched after the insertion has taken place. The target node of this event is the node being inserted. If the node is being directly inserted, the event type DOMNodeInserted occurs before this event type.

DOMNodeRemoved Event  
Event Object Type: dom.events.MutationEvent
MutationEvent.type property = DOMNodeRemoved

A node is being removed from its parent node or, in case of Attr nodes, removed from its ownerElement. This event is dispatched before the removal takes place. The target node of this event is the node being removed.

DOMNodeRemovedFromDocument Event  
Event Object Type: dom.events.MutationEvent
MutationEvent.type property = DOMNodeRemovedFromDocument

A node is being removed from a document, either through direct removal of the node or removal of a subtree in which it is contained; Attr nodes are considered part of an Element's subtree. This event is dispatched before the removal takes place. The target node of this event type is the node being removed. If the node is being directly removed, the event type DOMNodeRemoved occurs before this event type.

DOMSubtreeModified Event  
Event Object Type: dom.events.MutationEvent
MutationEvent.type property = DOMSubtreeModified

This is a general event for notification of all changes to the document. It can be used instead of the more specific mutation and mutation name events listed below. It may be dispatched after a single modification to the document or, at the implementation's discretion, after multiple changes have occurred. The latter use should generally be used to accommodate multiple changes which occur either simultaneously or in rapid succession. The target of this event is the lowest common parent of the changes which have taken place. This event is dispatched after any other events caused by the mutation(s) have occurred.