document.getElementById("print").innerHTML = good;
I want to start writing on new line when using this function for the second time
Here is what I would recommend:
print()
which you can call more easily.+=
to add and not overwrite content.br
elements to add line breaks after each printed message. printDiv = document.getElementById("print"); function print(text) { printDiv.innerHTML += text + '<br>'; } print('This text'); print('is just here'); print('to test the function');
<div id="print"></div>
You are generating HTML.
A new line in HTML is usually created with a <br>
element .
That might not be the right option for the data you are generating though. HTML is a semantic markup language so you should generate the markup that describes the semantics of the data you are working with.
That might involve creating a list with list items in it, multiple paragraphs, or something else.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.