Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
50
rated 0 times [  57] [ 7]  / answers: 1 / hits: 85679  / 14 Years ago, tue, december 14, 2010, 12:00:00

greetings all
i want to make JQuery sleep/wait for a second between two functions



$('#div1').hide();
//sleep or wait or for a sec
$(#div2).show();


how to do so ?


More From » jquery

 Answers
33

For your specific function .show() isn't queued, but there's an easy trick to make it queued so you can use .delay(), like this:



$('#div1').hide();
$(#div2).delay(1000).show(0);


By giving it a 0 duration argument, it's now an instant, but queued animation. Underneath this uses setTimeout(), so it's basically the same behavior as:



$('#div1').hide();
setTimeout(function() { $(#div2).show(); }, 1000);

[#94611] Saturday, December 11, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bradleymoisesy

Total Points: 121
Total Questions: 105
Total Answers: 95

Location: Nepal
Member since Mon, Jan 4, 2021
3 Years ago
bradleymoisesy questions
Wed, Dec 22, 21, 00:00, 3 Years ago
Tue, Jun 1, 21, 00:00, 3 Years ago
Thu, Jun 11, 20, 00:00, 4 Years ago
Thu, Jan 16, 20, 00:00, 4 Years ago
;