1
I have the following function:
function time() {
let today = new Date();
today.setMinutes(today.getMinutes() + 30);
let h = today.getHours().toString().padStart(2, '0');
let m = today.getMinutes().toString().padStart(2, '0');
let s = today.getSeconds().toString().padStart(2, '0');
document.getElementById('1').innerHTML = `${h}:${m}:${s}`;
}
This function is triggered when I press a button. But it needed that when the time that is played in HTML (in case local time + 30 min) was the local time, it would issue a alert
default or a pop up, with a message to the user.
Thank you, it worked perfectly. Could you tell me if it is possible to trigger an audible alert? Some library maybe?
– Riberox
@Riberox, if you have the audio file URL, you can use the native API
Audio
. He returns aHTMLAudioElement
which has a methodplay
that can be used to play the sound.– Luiz Felipe