My code writes to a text box and displays different lines of text using the SetTimeout function. But everytime it writes, it replaces the original text with the new text. What I would really like is for it to continue writing on a new line. I am very new to javascript so I need a little help with this. Here is my code so far:
putftp.onclick = function () {
var Text = document.getElementById("TextBox");
function firsttext() {
Text.innerHTML = "This is the first test.";
setTimeout(secondtest, 3000);
}
function secondtest() {
Text.innerHTML = "This is the second test.";
setTimeout(thirdtest, 5000);
I would like the output to be
This is the first test.
This is the second test.
instead of
This is the second test.
Any help would be greatly appreciated!!
You will need to concatenate the contents of innerHTML together. Currently you’re simply changing its value: