Delay js function

113

jquery delay to call function -

 $(this).delay(1000).queue(function() {

     // your Code | Function here
     
     $(this).dequeue();
  
  });

delay javascript function -

console.log("Hello");
setTimeout(() => { console.log("World!"); }, 2000);
console.log("Goodbye!");

how create a delay for html js -

console.log("Hello");
setTimeout(() => {  console.log("World!"); }, 2000);

javascipt delay -

function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

console.log("Hello");
sleep(2000).then(() => { console.log("World!"); });

Comments

Submit
0 Comments