Jquery $('#div')。show()。delay(5000).hide();不工作 [英] Jquery $('#div').show().delay(5000).hide(); doesn't work

查看:461
本文介绍了Jquery $('#div')。show()。delay(5000).hide();不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图显示一个div,设置为 display:none; 5秒,

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

但它不工作,它只是直接隐藏()

$ b

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

通过将数字传递到 .show() .hide(),jQuery会将这些方法放入其内部的 fx队列(即使数字为零)。由于 .delay()只能在队列中使用,因此您需要一些解决方法。



示例: http://jsfiddle.net/zceKN/


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?

解决方案

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/

这篇关于Jquery $('#div')。show()。delay(5000).hide();不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆