6

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 !!!

3 Answers 3

13

Use setTimeout

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

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

0
1

You can use .delay() like this:

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

But be aware that .hide() needs to have (time) parameter to work in conjunction with .delay()

1
  • hide and show with a passed in duration property behaves like effects.. So it will work in such cases. But does not if the parameter is ommitted Jun 21, 2013 at 20:03
0

Is this what you meant?

jQuery("#tem_forma").hide();
jQuery("#win").delay(3000).hide(1000);
2
  • That is because you are passing the duration property.. It does not work without any parametrs Jun 21, 2013 at 20:00
  • You are correct but the OP also had params. I was aiming for less code. Jun 21, 2013 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.