How to make a function to display after 5 or 6 seconds
function a() {
alert("after 5 seconds");
}
a();
How to make a function to display after 5 or 6 seconds
function a() {
alert("after 5 seconds");
}
a();
You can use all JS timers that you want.
setTimeout/setInterval, etc.
var duration = 5000; #in ms, miliseconds. 5000 = 5s
function delayedAlert() {
window.setTimeout(slowAlert, 5000);
}
function slowAlert() {
alert('That was really slow!');
}
Look more in https://developer.mozilla.org/en-US/Add-ons/Code_snippets/Timers
function delayer(ms){
return new Promise((resolve, reject)=>{
setTimeout(()=>{
resolve();
}, ms)
})
}
async function myFunction(){ // Function Must be async.
console.log("First Console")
await delayer(3000); // This Will Stop The Code For 3 Seconds
console.log("Second Console After 3 Seconds")
}
myFunction()