Adding a line Break into JS | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Adding a line Break into JS

This is my code here I’ve tried adding a \n into it but it doesn’t add a line break. I’ve also tried <br/> with no luck: var i = 0; var txt = "Welcome : Made by Ole113"; var speed = 70; function typeWriter() { if (i < txt.length) { document.getElementById("demo").innerHTML += txt.charAt(i); i++; setTimeout(typeWriter, speed); } }

31st Jan 2018, 11:12 PM
Ole113
Ole113 - avatar
2 Answers
+ 11
Use this CSS property body { word-break:break-all; }
1st Feb 2018, 8:13 AM
Ranjan Bagri
Ranjan Bagri - avatar
+ 5
I have doing like that and it didn't work. I have tried a crazy idea open my code below, go to js section, search a commented code in line 139 to 194. not for advertising https://code.sololearn.com/WH3xv416vBM9/?ref=app
1st Feb 2018, 12:21 AM
Amethyst Animion
Amethyst Animion - avatar