Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
71
rated 0 times [  73] [ 2]  / answers: 1 / hits: 82017  / 13 Years ago, fri, september 2, 2011, 12:00:00

I'm trying to show a div thats set to display: none; for 5 seconds with



$('#div').show().delay(5000).hide();


but it deson't work, it just goes straight to hide()



Can any of you help me?


More From » jquery

 Answers
54

Do it like this:



$('#div').show(0).delay(5000).hide(0);


By passing in numbers to .show() and .hide(), jQuery will take those methods into its internal fx queue (even if the number is zero). Since .delay() only works within a queue, you need that little workaround.



example: http://jsfiddle.net/zceKN/


[#90292] Thursday, September 1, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
albert

Total Points: 652
Total Questions: 105
Total Answers: 108

Location: Pitcairn Islands
Member since Fri, Oct 15, 2021
3 Years ago
;