How can I update a div using setInterval?
How can I update a div using setInterval?
You can update the div with innerHTML
within setInterval
.
Here's an example:
setInterval(function() {
document.getElementById("relogio").innerHTML = new Date();
}, 1000);
<div id="relogio"></div>
Basic syntax of setInterval
:
setInterval(<function>, <milliseconds>);
More on setInterval
: link