Blogger Ever

Trigger Javascript function after a pause (delay)

Delay a Javascript function or trigger it after a pause of a specific time. For that using setTimeout() function.

Animation in jQuery can be delay using .delay() function but you can't practically delay a function with this method, you need something different for that. I'll go for pure JS.

Timeout function, the solution for your delay in triggering an event. Well, nothing complex just add setTimeout(function,time).

Lets create a popup menu that will popup 5 seconds after the button click. So we need is to just add on click event and add the timeout function to trigger that. Have a look at the demo.
See the Pen gbLzNw by Mohammad Hamza Dhamiya (@hamzadhamiya) on CodePen.

2013-2016 Copyright Blogger E\ver . Coded, managed and founded by Mohammad Hamza (@hamzadhamiya) . Hosted on Blogger and fonts used are Raleway and Open Sans.