Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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.

MethodDescription
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.

PropertyDescription

childElementCount

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.

constructor

Returns a reference to the constructor of an object.

expando

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

firstChild

Gets a reference to the first child in the childNodes collection of the object.

firstElementChild

Retrieves a reference to the first child element, or null if there are no child elements.

lastChild

Gets a reference to the last child in the childNodes collection of an object.

lastElementChild

Retrieves a reference to the last child element or null if there are no child elements.

localName

Retrieves the local name of the fully qualified XML declaration for a node.

name

Sets or retrieves the name of the object.

namespaceURI

Retrieves the namespace URI of the fully qualified XML declaration for a node.

nextElementSibling

Retrieves a reference to the sibling element that immediately follows or null if the element does not have any sibling elements that follow it.

nextSibling

Retrieves a reference to the next child of the parent for the object.

nodeName

Gets the name of a particular type of node.

nodeType

Retrieves the type of the requested node.

nodeValue

Gets or sets the value of a node.

ownerDocument

Retrieves the document object associated with the node.

ownerElement

Retrieves the element that owns the attribute.

parentNode

Retrieves the parent object in the document hierarchy.

prefix

Retrieves the local name of the fully qualified XML declaration for a node.

previousElementSibling

Retrieves a reference to the immediately preceding sibling element or null if the element does not have any preceding siblings.

previousSibling

Gets a reference to the previous child of the parent for the object.

specified

Gets a value that indicates whether an attribute is explicitly given a value.

textContent

Sets or retrieves the text content of an object and any child objects.

value

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.

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){
         console.log(oList.attributes[i].nodeName + " = "
          + oList.attributes[i].nodeValue);
      }
   }
}
</script>
<ul onclick="fnFind()">
<li id = "myList" accesskey = "l">List Item 1
</ul>

 

 

Show:
© 2014 Microsoft