i have a a code like that:
<p id = "outputLaps"></p>
JS:
document.getElementById("outputLaps").innerHTML = "Number of lap: " + numberOfLap + " time: " + minutes + ":" + seconds + ":0" + milliseconds
and i don't want to rewrite it, but to display it under the previous "lap". Thanks for answers :).
Use insertAdjacentHTML when you want to insert HTML.
var str = "Number of lap: " + numberOfLap + " time: " + minutes + ":" + seconds + ":0" + milliseconds;
document.getElementById("outputLaps").insertAdjacentHTML("beforeend", str);
However, if you only want to insert text, you can append a text node:
var str = "Number of lap: " + numberOfLap + " time: " + minutes + ":" + seconds + ":0" + milliseconds;
document.getElementById("outputLaps").appendChild(
document.createTextNode(str)
);
In case you want the text to go to the next line, you can either
\n and style the paragraph with white-space set to pre, pre-wrap or pre-line.<br /> HTML element.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