\n | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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