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.

Sign up to request clarification or add additional context in comments.

Comments

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 Comment

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
0

Is this what you meant?

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

2 Comments

That is because you are passing the duration property.. It does not work without any parametrs
You are correct but the OP also had params. I was aiming for less code.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.