Here is what I tried so far:
var zlp = document.getElementById("testDiv") zlp.innerHTML = "hello hello" var zzz = document.createTextNode("hello hello") zlp.appendChild(zzz)
Both of which produce
You can replace it with the
var text = text.replace(/s/g, ' ');
s will match any white space character, such as space, tab and new line. If you only want to replace space, use
/ /g instead.
Other options which avoid string manipulation: