Javascript Reference
Categories: Node

javascript Node nodeName

@March 15, 2008, 1:22 a.m.
nodeNameFirefox/Netscape/NN 6 IE 5 Chrome/Safari/DOM 1  

Read-only  

Returns a string that identifies the name of the node as influenced by the node type. For element and attribute node types, the property returns the tag name and attribute name, respectively. For many other kinds of nodes, which have no inherent label associated with them, the nodeName property returns a fixed string indicating the node type, such as #text for a text node and #document for the root document node. For elements, the property returns the same string value as the element object's tagName property. Note that browsers through IE 6 and Netscape 7 return element tag strings in all uppercase, regardless of source code style or DOCTYPE specification.

 
Example
 
if (document.getElementById("elementID").nextSibling.nodeName == "#text") {
    // process as a text node
}
 
Value

Fixed string for #cdata-section, #document, #document-fragment, and #text nodes; variable string for attribute, element, and other node types.

 
Default

Node-specific.


Powered by Linode.