0
\n
The \n doesnÂŽt work in my code. It doesnÂŽt create a new line. How do i have to use it?
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 /
+ 1
Can you please show your code in which it is not working?
+ 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