Latest web development tutorials

HTML DOM nodeValue property

Elements Object Reference Element object

Examples

Get value of the first node button element:

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

Output:

尝试一下

try it"

Definition and Usage

Depending on the type of node nodeValue property sets or returns the value of a node.

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

Tip: Another way to get the value of an attribute node textContent property .


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support nodeValue property


grammar

Set the node values:

node .nodeValue= value

Returns the node value:

node .nodeValue

technical details

return value: String node value.
DOM version Core Level 1 Node Object


Elements Object Reference Element object