Sometimes, we want to replace from JavaScript DOM text node.
In this article, we’ll look at how to replace from JavaScript DOM text node.
How to replace from JavaScript DOM text node?
To replace from JavaScript DOM text node, we can use the string replace method.
For instance, we write
textNode.nodeValue = textNode.nodeValue.replace(/\u00a0/g, " ");
to call nodeValue.replace with /\u00a0/g and ' ' to replace all characters with spaces in our text node.
Conclusion
To replace from JavaScript DOM text node, we can use the string replace method.