Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery delay function execute

I want execute 2 functions in jquery but i need the second function execute after 3 seconds more or less , i try this , but if use this , the second function of jquery never execute finally , i put the script i create and i try works continue :

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

How i can use delay function for wait 3 seconds for execute the next function , in this case the second

Thank´s , Regards !!!

like image 726
user2501504 Avatar asked Jun 21 '13 19:06

user2501504


People also ask

How do you execute a function after a delay?

We will use the Timer() and schedule() functions to call a function after a delay. Let's look at an example of this function.

Is delay () A event method in jQuery?

Added to jQuery in version 1.4, the . delay() method allows us to delay the execution of functions that follow it in the queue. It can be used with the standard effects queue or with a custom queue. Only subsequent events in a queue are delayed; for example this will not delay the no-arguments forms of .

How can we call a function automatically after waiting for some time in jQuery?

In order to run a function automatically after waiting for some time, we are using the jQuery delay() method. The . delay() method in jQuery which is used to set a timer to delay the execution of the next item in the queue.


1 Answers

Use setTimeout

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

This will make sure your functions gets executed after 3 seconds.

like image 199
Sushanth -- Avatar answered Sep 21 '22 01:09

Sushanth --