attribute object
Represents an attribute or property of an HTML element as an object.
Members
The attribute object has these types of members:
Methods
The attribute object has these methods.
| Method | Description |
|---|---|
| appendChild |
Appends an element as a child to the object. |
| cloneNode |
Copies a reference to the object from the document hierarchy. |
| compareDocumentPosition |
Compares the position of two nodes in a document. |
| 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. |
| isDefaultNamespace |
Indicates whether or not a namespace is the default namespace for a document. |
| isEqualNode |
Determines if two nodes are equal. |
| isSameNode |
Determines if two node references refer to the same node. |
| isSupported |
Returns a value indicating whether or not the object supports a specific DOM standard. |
| lookupNamespaceURI |
Gets the URI of the namespace associated with a namespace prefix, if any. |
| lookupPrefix |
Gets the namespace prefix associated with a URI, if any. |
| normalize |
Merges adjacent DOM objects to produce a normalized document object model. |
| removeChild |
Removes a child node from the object. |
| removeNode |
Removes the object from the document hierarchy. |
| replaceChild |
Replaces an existing child element with a new child element. |
| replaceNode |
Replaces the object with another element. |
| swapNode |
Exchanges the location of two objects in the document hierarchy. |
Properties
The attribute object has these properties.
| Property | Description |
|---|---|
|
Retrieves the number of immediate child nodes of the current element or a zero if the element does not contain any child nodes. childElementCount does not return all child nodes, only child nodes that are nodeType =1, or element nodes. | |
|
Returns a reference to the constructor of an object. | |
|
Sets or retrieves a value indicating whether arbitrary variables can be created within the object. | |
|
Gets a reference to the first child in the childNodes collection of the object. | |
|
Retrieves a reference to the first child element, or null if there are no child elements. | |
|
Gets a reference to the last child in the childNodes collection of an object. | |
|
Retrieves a reference to the last child element or null if there are no child elements. | |
|
Retrieves the local name of the fully qualified XML declaration for a node. | |
|
Sets or retrieves the name of the object. | |
|
Retrieves the namespace URI of the fully qualified XML declaration for a node. | |
|
Retrieves a reference to the sibling element that immediately follows or null if the element does not have any sibling elements that follow it. | |
|
Retrieves a reference to the next child of the parent for the object. | |
|
Gets the name of a particular type of node. | |
|
Retrieves the type of the requested node. | |
|
Gets or sets the value of a node. | |
|
Retrieves the document object associated with the node. | |
|
Retrieves the element that owns the attribute. | |
|
Retrieves the parent object in the document hierarchy. | |
|
Retrieves the local name of the fully qualified XML declaration for a node. | |
|
Retrieves a reference to the immediately preceding sibling element or null if the element does not have any preceding siblings. | |
|
Gets a reference to the previous child of the parent for the object. | |
|
Gets a value that indicates whether an attribute is explicitly given a value. | |
|
Sets or retrieves the text content of an object and any child objects. | |
|
Gets or sets the value of the object. |
Standards information
There are no standards that apply here.
Remarks
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.
When displaying a Web page in IE8 Standards mode, Windows Internet Explorer distinguishes between attribute values specified by the original page author and the representation of those values in the DOM. For more information, see Attribute Differences in Internet Explorer 8.
This object is available in script as of Microsoft Internet Explorer 5.
Examples
This example uses the attribute object to create a list of attributes that are specified.
<script type="text/javascript"> function fnFind(){ var oList = document.getElementById("myList"); 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 = "myList" accesskey = "l">List Item 1 </ul>