I've made a timer but I need something to happen every 5 or 10 seconds. I don't want to use a setTimeout or setInterval function, but when I use this timer, I don't know how to address the value of seconds. should it be written like 5000 or something else?
function display(){
var endTime = new Date();
var timeDiff = endTime - startTime;
timeDiff /= 1000;
var seconds = Math.round(timeDiff % 60);
timeDiff = Math.floor(timeDiff / 60);
//showing the seconds passed
$("#time").text(seconds);
setTimeout(display,1000);
}
//starts the timer
$("#start").click(function() {
startTime = new Date();
setTimeout(display,1000);
});
/confirms it is 5 seconds
if (timeDiff == 5){
alert('now');
}