About

Labels

slider

Recent

Navigation

Trigger Javascript function after a pause (delay)


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.
Share
Banner

Muhammad Hamza

Themelet provides the best in market today. We work hard to make the clean, modern and SEO friendly blogger templates.

Post A Comment:

0 comments: