A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/dom/Node/nodeValue below:

nodeValue ยท WebPlatform Docs

nodeValue Summary

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

Property of dom/Nodedom/Node

Syntax
var value = node.nodeValue;
node.nodeValue = newValue;
Return Value

Returns an object of type StringString

The value of the node.

Examples

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>
<html>
<head>
<title>Title</title>
<script>
function changeValue(list, itemIndex, newValue) {
   
   if (list.nodeName !== "UL" && list.nodeName != "OL")
      return false;
   
   
   if (itemIndex > list.childNodes.length -1)
      return false;
   
   var liElements = list.childNodes[itemIndex];
   if (!liElements)
      return false;
   
   var textNode = liElements.childNodes[0];
   
   if (textNode.nodeType !== 3)
      return false;
   textNode.nodeValue = newValue;
   return true;
}
function initialize() {
  document.getElementById("list").addEventListener(
    "click",
    function () {
     changeValue(this, 0, "New Node value");
    },
    false);
}
document.addEventListener("DOMContentLoaded", initialize, false);
</script>
</head>
<body>
<ul id="list"><li>Old Node Value</li></ul>
</body>
Usage
 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).
Notes Related specifications
DOM Level 3 Core
W3C Recommendation
WHATWG DOM
Living Standard
Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4