Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
90
rated 0 times [  94] [ 4]  / answers: 1 / hits: 53988  / 13 Years ago, wed, november 16, 2011, 12:00:00

I insert several textNodes in javascript, and can't figure out how to separate them with carriage returns. I've tried putting n, r, and
but none of them work



var textNode = document.createTextNode(Node on line 1);
element.appendChild(textNode);

textNode = document.createTextNode(Node on line 2);
element.appendChild(textNode);


I want this to appear as:



Node on line 1



Node on line 2



NOT



Node on line 1Node on line2



Any tips on how I can accomplish this ?


More From » javascript

 Answers
294

Use <br> to separate them as like this



var br = document.createElement(br);
element.appendChild(br);

[#89094] Tuesday, November 15, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
corie

Total Points: 371
Total Questions: 110
Total Answers: 113

Location: Cambodia
Member since Thu, Oct 7, 2021
3 Years ago
;