There is a function that writes a line ( document.write ).
It is called via setInterval () .
Why does setInterval remove all HTML elements instead of adding text to them?
var seconds = 1; function repeatWrite(){ document.write(seconds + " seconds left" + "<br>"); seconds++ } setInterval(repeatWrite, 1000); <h1>Появляющийся текст!</h1> <p>Каждую секунду ниже должен появляться текст</p> <p>Но почему все эти HTML элементы исчезают?</p>
document.writereplaces the contents of the document. - user207618