Q:

How to display multi-line text on a single line

I get a string from innerHtml. The string is on two lines, as you can see from the image I attached below:

What I'm trying to do is to display it in one line. I've tried this, but it did not work:
var dataToAdd = v.innerHTML.replace("\r\n", "" );

A:

Changing it to a regex with global modifier to do it for multiple lines and to separate the newline and carriage return. Your replace function searches for both characters after another and replace that, but often you wont have a carriage return.

var dataToAdd = document.getElementById("test").innerHTML.replace(/[\n\r]/g, "" );
console.log(dataToAdd);
<div id="test">1
2
3
</div>

