How to make a function delay 5 seconds in javascript -


how make function display after 5 or 6 seconds

    function a() { alert("after 5 seconds"); }  a(); 

you can use js timers want.

settimeout/setinterval, etc.

var duration = 5000; #in ms, miliseconds. 5000 = 5s  function delayedalert() {   window.settimeout(slowalert, 5000); }  function slowalert() {   alert('that slow!'); } 

look more in https://developer.mozilla.org/en-us/add-ons/code_snippets/timers


Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -