This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.



Gets or sets the value of a Node, if the type of Node supports it.

Property of dom/Nodedom/Node


var value = node.nodeValue;
node.nodeValue = newValue;

Return Value

Returns an object of type StringString

The value of the node.


The following code example alters the text of the specified list item by setting the nodeValue property of the text node that is contained by that list item.

<!DOCTYPE html>
function changeValue(list, itemIndex, newValue) {
   // only perform the operation on lists
   if (list.nodeName !== "UL" && list.nodeName != "OL")
      return false;
   // only perform the operation if the specified index is
   // within the acceptable range of available list items
   if (itemIndex > list.childNodes.length -1)
      return false;
   // get a reference to the specified list item
   var liElements = list.childNodes[itemIndex];
   if (!liElements)
      return false;
   // get a reference to the text node contained by the list item
   var textNode = liElements.childNodes[0];
   // ensure that the node is a text node
   if (textNode.nodeType !== 3)
      return false;
   textNode.nodeValue = newValue;
   return true;
function initialize() {
    function () {
     changeValue(this, 0, "New Node value");
document.addEventListener("DOMContentLoaded", initialize, false);
<ul id="list"><li>Old Node Value</li></ul>


 Use this property to get or set the value of a Node. The concept of nodeValue changes between the various Node types (Element, Text and the rest).


Related specifications

DOM Level 3 Core
W3C Recommendation
Living Standard