I have a tiny script which should update a span with the current time.
This script works BEFORE the setInterval but not during the setInterval.
HTML:
<?= date("d/m/Y") ?> <span id="time"></span>
Javascript:
$(document).ready(function(){
var dt = new Date();
var time = dt.getHours() + ":" + dt.getMinutes();
$("#time").text(time);
setInterval(function(){
console.log("interval");
time = dt.getHours() + ":" + dt.getMinutes();
$("#time").text(time);
},5000);
});
The span with id time just doesn't change the time.