Using setInterval [closed]

-2

How can I update a div using setInterval?

    
asked by anonymous 19.08.2017 / 14:17

1 answer

1

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

    
19.08.2017 / 16:11