Categories
JavaScript Answers

How to change text node value with JavaScript?

Spread the love

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.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.