HTML DOM nodeValueProperty

元素对象参考手册Element Object

Example

Get the node value of the first button element:

document.getElementsByTagName("BUTTON")[0].childNodes[0].nodeValue;

Output result:

Try it

Try it »

Definition and Usage

The nodeValue property sets or returns the value of a node according to its type.

Note:If you want to return the text of an element, remember that text is usually inserted into a text node, so what is returned is the node value of the text node (element.childNodes[0].nodeValue)。

Tip:Another property for getting the node valuetextContent Property.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the nodeValue property


Syntax

Set the node value:

node.nodeValue=value

Return the node value:

node.nodeValue

Technical Details

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


元素对象参考手册Element Object

Other Extensions