0

\n

The \n doesnÂŽt work in my code. It doesnÂŽt create a new line. How do i have to use it?

6th Jan 2020, 3:37 PM
Samu H.
Samu H. - avatar
3 Respostas
+ 2
Samu H. It'll work in console.log and alert ,prompt ,confirm methods. however if you are trying to use it while adding or changing text content in DOM it'll not work due to white space collapsing. By default all multiple spaces ,tabs, newlines will be rendered as single space. ●css way: use white-space:pre-line; ●fix from js itself : targetElement.innerHTML="some text <br> with newlines"; notice use of <br> instead of \n would be better if you show your code /
6th Jan 2020, 4:08 PM
🇼🇳Omkar🕉
🇼🇳Omkar🕉 - avatar
+ 1
Can you please show your code in which it is not working?
6th Jan 2020, 3:53 PM
ăƒœ(^。^)ăƒŽâœšăƒœ(^。^)ノ
ăƒœ(^。^)ăƒŽâœšăƒœ(^。^)ノ - avatar
+ 1
"The \n doesn't work in my code" But where is the code? share your code in question Description. Follow this guide on how to share links https://www.sololearn.com/post/74857/?ref=app
6th Jan 2020, 3:54 PM
Ipang