Why Breaking Line (\n) Doesn't Work In My Code?
I'm creating table of TV providers and contacts to them. The general functionality you can see there: https://imgur.com/u5uREJm Table is constructed in way, that in each row is bu
Solution 1:
As I think you know, all whitespace including tabs and newlines in HTML is rendered as a single normal space. To get line breaks without the CSS properties you were using, you'll need to separate them into distinct text nodes with a br
element in-between. Roughly:
let newCell2 = newRow.insertCell(1);
let first = true;
for (const entry of provInfoEmail.split("\n")) {
if (first) {
first = false;
} else {
newCell.appendChild(document.createElement("br"));
}
}
That post-processes your string with \n
in it. Obviously if you can do this earlier (when you were figuring out where the \n
should be), that would be better.
Post a Comment for "Why Breaking Line (\n) Doesn't Work In My Code?"