+ 4

\n control character

Why control character \n working in code alert ('Hello \n world'); But doesn't working inside contruction ? document.write('Hello \n world');

15th Jan 2017, 8:00 AM
Alexandr Kashuba
Alexandr  Kashuba - avatar
2 ответов
+ 7
Use double quotes when outputting escaped characters, think of them as special. May I ask why you call it the control character, when in fact it's the "new line" character? Try using element.innerHTML and use break <br> the new line character just looks wrong here. Good luck.
27th Feb 2017, 9:09 PM
Mark Foxx
Mark Foxx - avatar
+ 2
The same result with double quotes. And working with console.log('Hello \n world'); <br> work well with document.write(). Yes you right new line character my mistake in translation.
28th Feb 2017, 1:22 PM
Alexandr Kashuba
Alexandr  Kashuba - avatar