Categories
JavaScript Answers

How to replace nbsp; from JavaScript DOM text node?

Spread the love

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.

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.