4html:
current date: <span id="cd"></span><br />
time to Alarm: <span id="al1"></span><br />
alarm Triggered: <span id="al1stat"> false</span><br />
javascript:
var setAlarm1 = "14"; //14:00, 2:00 PM
var int1 = setInterval(function(){
var currentHour = new Date().getHours();
var currentMin = new Date().getMinutes();
$('#cd').html(currentHour + ":" + currentMin);
$('#al1').html(setAlarm1 - currentHour + " hours");
if(currentHour >= setAlarm1){
$('#al1stat').html(" true");
clearInterval(int1);
//call to function to trigger : triggerFunction();
}
},1000) //check time on 1s
muestra a: http://jsfiddle.net/yhDVx/4/
Deberá el evento disparado automáticamente, o sólo a una punto de tiempo particular? – reporter
Duplicado: http://stackoverflow.com/questions/4455282/call-a-javascript-function-at-a-specific-time-of-day –