HTML DOM nodeNameProperty

元素对象参考手册Element Object

Examples

Get the node name of the body element:

document.body.nodeName;

Output result:

BODY

Try it Yourself »

Definition and Usage

The nodeName property returns the name of a node based on its type.

If the node is an element node, the nodeName property will return the tag name.

If the node is an attribute node, the nodeName property will return the attribute name.

For other node types, the nodeName property will return different node names depending on the node type.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the nodeName property


Syntax

node.nodeName

Technical Details

Return value: A string, representing the name of the node.
DOM Version Core Level 1 Node Object


元素对象参考手册Element Object

Other Extensions