Executing Jquery Delay Function

I want to execute 2 functions in jquery, but I need the second function to be executed in 3 seconds or more, I try to do this, but if you use this, the second jquery function will never be executed, I will put the script I create and I try to continue job:

jQuery("#tem_forma").hide(); delay(3000); jQuery("#win").hide(1000); 

How can I use the delay function to wait 3 seconds to perform the next function, in this case the second

Thanks, Regards !!!

+6
source share
3 answers

Use setTimeout

 jQuery("#tem_forma").hide(); setTimeout( function() { jQuery("#win").hide(1000); }, 3000); 

This will ensure that your functions complete in 3 seconds.

+13
source

You can use .delay() as follows:

 jQuery("#tem_forma").hide(); jQuery("#win").delay(3000).hide(1000); 

But keep in mind that .hide() must have a (time) parameter to work in conjunction with .delay()

+1
source

Is that what you meant?

 jQuery("#tem_forma").hide(); jQuery("#win").delay(3000).hide(1000); 
0
source

Source: https://habr.com/ru/post/947865/


All Articles