attribute Object

Represents an attribute or property of an HTML element as an object.

Members Table

The following table lists the members exposed by the attribute object.

Attributes/Properties
AttributePropertyDescription
constructor New for Windows Internet Explorer 8  Returns a reference to the constructor of an object.
expando Retrieves a value indicating whether arbitrary variables can be created within the object.
firstChild Retrieves a reference to the first child in the childNodes collection of the object.
lastChild Retrieves a reference to the last child in the childNodes collection of an object.
NAMEname Sets or retrieves the name of the object.
nextSibling Retrieves a reference to the next child of the parent for the object.
nodeName Retrieves the name of a particular type of node.
nodeType Retrieves the type of the requested node.
nodeValue Sets or retrieves the value of a node.
ownerDocument Retrieves the document object associated with the node.
ownerElement New for Internet Explorer 8  Retrieves the element that owns the attribute.
parentNode Retrieves the parent object in the document hierarchy.
previousSibling Retrieves a reference to the previous child of the parent for the object.
specified Gets whether an attribute has been specified.
value Sets or gets the value of the object.
Collections
CollectionDescription
attributes Retrieves the collection of attributes belonging to the object.
childNodes Retrieves a collection of HTML Elements and TextNode objects that are direct descendants of the specified object.
Methods
MethodDescription
appendChild Appends an element as a child to the object.
cloneNode Copies a reference to the object from the document hierarchy.
hasChildNodes Returns a value that indicates whether the object has children.
insertBefore Inserts an element into the document hierarchy as a child node of a parent object.
removeChild Removes a child node from the object.
replaceChild Replaces an existing child element with a new child element.
Prototypes
ObjectDescription
Attr Constructor New for Internet Explorer 8  Defines the properties and methods inherited by objects in the Attr Constructor prototype chain.
CSSRuleStyleDeclaration Constructor New for Internet Explorer 8  Defines the properties and methods inherited by objects in the CSSRuleStyleDeclaration Constructor prototype chain.
CSSStyleDeclaration Constructor New for Internet Explorer 8  Defines the properties and methods inherited by objects in the CSSStyleDeclaration Constructor prototype chain.
HTCBehavior Constructor New for Internet Explorer 8  Defines the properties and methods inherited by objects in the HTCBehavior Constructor prototype chain.
HTCElementBehaviorDefaults Constructor New for Internet Explorer 8  Defines the properties and methods inherited by objects in the HTCElementBehaviorDefaults Constructor prototype chain.
HTMLModelessDialog Constructor New for Internet Explorer 8  Defines the properties and methods inherited by objects in the HTMLModelessDialog Constructor prototype chain.
NamedNodeMap Constructor New for Internet Explorer 8  Defines the properties and methods inherited by objects in the NamedNodeMap Constructor prototype chain.
NodeList Constructor New for Internet Explorer 8  Defines the properties and methods inherited by objects in the NodeList Constructor prototype chain.
StaticNodeList Constructor New for Internet Explorer 8  Defines the properties and methods inherited by objects in the StaticNodeList Constructor prototype chain.

Remarks

 New for Internet Explorer 8 When displaying a Web page in IE8 mode, Internet Explorer distinguishes between attribute values specified by the original page author and the representation of those values in the Document Object Model (DOM). For more information, see Attribute Differences in Internet Explorer 8.

The attribute object is accessible through the attributes collection.

A valid attribute or property can be any Dynamic HTML (DHTML) property or event that applies to the object, or an expando.

This object is available in script as of Microsoft Internet Explorer 5.

Example

This example uses the attribute object to create a list of attributes that are specified.

<SCRIPT>
function fnFind(){
   for(var i=0;i<oList.attributes.length;i++){
      if(oList.attributes[i].specified){
         alert(oList.attributes[i].nodeName + " = "
          + oList.attributes[i].nodeValue);
      }
   }
}
</SCRIPT>

<UL onclick="fnFind()">
<LI ID = "oList" ACCESSKEY = "L">List Item 1
</UL>

Standards Information

There is no public standard that applies to this object.

Tags :


Page view tracker