function displayTime() {
var elt = document.getElementById("clock");
console.log(elt)
var now = new Date();
elt.innerHTML = now.toLocaleTimeString();
setTimeout(displayTime, 1000);
}
window.onlaod = displayTime;
clock
<div id="clock"></div>
function displayTime() {
var elt = document.getElementById("clock");
var now = new Date();
elt.innerHTML = now.toLocaleTimeString();
setTimeout(displayTime, 1000);
}
window.onload = displayTime;