Sometimes, we want to change text node value with JavaScript.
In this article, we’ll look at how to change text node value with JavaScript.
How to change text node value with JavaScript?
To change text node value with JavaScript, we can set the nodeValue property.
For instance, we write
node.nodeValue = "new value";
to set the text node‘s nodeValue to a string.
Setting nodeValue will only set the value of the text node and not affect descending nodes.
Conclusion
To change text node value with JavaScript, we can set the nodeValue property.