'Can we make timer in alert using javascript?
I want to make an alert that has a timer in it, the alert will show this message:
Please wait to process data 3 second..
Please wait to process data 2 second..
Please wait to process data 1 second..
and if the timer is done, the text will change to:
Succesfully process data..
I tried this one:
function countdown() {
var seconds = 3;
function tick() {
var counter = document.getElementById("counter");
seconds--;
counter.innerHTML = "Please wait to process data " + String(seconds)+ " Second";
if( seconds > 0 ) {
setTimeout(tick, 1000);
} else {
alert("Succesfully process data");
}
}
tick();
}
countdown();
<div id="results"></div>
<button id="stop">Stop</button>
but this code will show the timer in div, not in alert. I tried to edit to make it show in alert but still can not figure it out.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
