Why the line break \n does not work in document.write ?
document.write("lalala \n lalala"); Why the line break \n does not work in document.write ?
document.write("lalala \n lalala"); Because the browser ignores hyphens, tabs, pl. spaces and other special characters during page rendering.
Solution 1
document.write ("lalala <br \/> lalala"); Solution 2
document.write ("<pre>lalala \n lalala<\/pre>"); .write writes text. Any javascript values will result in text format when they are output to a document - Mike Nov.He works. But the default browser groups all the whitespace characters into one space. It is necessary to slightly change the css to get what you want:
document.write("lalala \n lalala"); body { white-space: pre-line; } Source: https://ru.stackoverflow.com/questions/469744/
All Articles