The code is like this:
$('#description').text(info + '<br>' + footnote);
But instead of:
Welcome to the website!
Copyright (c) 2015
It shows:
Welcome to the website!<br>Copyright (c) 2015
If I change '<br>' to '\n', then it displayed as nothing (white space)
Welcome to the website! Copyright (c) 2015
How can I add newline to a div using jQuery? Thanks.
That is because you are using .text(), which will escape any HTML tags in it (emphasis my own):
We need to be aware that this method escapes the string provided as necessary so that it will render correctly in HTML. To do so, it calls the DOM method
.createTextNode(), does not interpret the string as HTML.
Use .html() instead:
$('#description').html(info + '<br>' + footnote);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With