如何在Jquery中将delay()与show()和hide()一起使用

发布于 2024-10-09 01:58:14 字数 91 浏览 0 评论 0原文

如何在 Jquery 中将 delay()show()hide() 一起使用?

How can I use delay() with show() and hide() in Jquery ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

情何以堪。 2024-10-16 01:58:14

持续时间传递给show()hide()

当提供持续时间时,.show() 成为动画方法。

例如 element.delay(1000).show(0)

DEMO< /a>

Pass a duration to show() and hide():

When a duration is provided, .show() becomes an animation method.

E.g. element.delay(1000).show(0)

DEMO

云之铃。 2024-10-16 01:58:14

最简单的方法就是用jquery制作一个“假节目”。

element.delay(1000).fadeIn(0); // This will work

The easiest way is to make a "fake show" by using jquery.

element.delay(1000).fadeIn(0); // This will work
百善笑为先 2024-10-16 01:58:14

为什么不尝试fadeIn()而不是使用带有delay()的show()。
我认为你想做的事情可以用这个来完成。
下面是 fadeIn 和 FadeOut() 的 jQuery 代码,它也有用于延迟过程的内置方法。

$(document).ready(function(){
   $('element').click(function(){
      //effects take place in 3000ms
      $('element_to_hide').fadeOut(3000);
      $('element_to_show').fadeIn(3000);
   });
}

Why don't you try the fadeIn() instead of using a show() with delay().
I think what you are trying to do can be done with this.
Here is the jQuery code for fadeIn and FadeOut() which also has inbuilt method for delaying the process.

$(document).ready(function(){
   $('element').click(function(){
      //effects take place in 3000ms
      $('element_to_hide').fadeOut(3000);
      $('element_to_show').fadeIn(3000);
   });
}
来日方长 2024-10-16 01:58:14

来自 jquery api

在 1.4 版本中添加到 jQuery 中,.delay() 方法允许我们延迟执行队列中跟随它的函数。它可以与标准效果队列或自定义队列一起使用。仅延迟队列中的后续事件;例如,这不会延迟不使用效果队列的 .show().hide() 的无参数形式。

http://api.jquery.com/delay/

from jquery api

Added to jQuery in version 1.4, the .delay() method allows us to delay the execution of functions that follow it in the queue. It can be used with the standard effects queue or with a custom queue. Only subsequent events in a queue are delayed; for example this will not delay the no-arguments forms of .show() or .hide() which do not use the effects queue.

http://api.jquery.com/delay/

梦一生花开无言 2024-10-16 01:58:14

此信息需要更新。

我今天看到这个是因为我需要延迟 div 的显示。我正在使用 jQuery 3.4.1 并对此进行了测试。

 $("#mydiv").delay(5000).show(200); // a 5 second delay before the 200 microseconds animation effect from hidden to visible is triggered.

This info needs updating.

I was looking at this today because I needed to delay the showing of a div. I'm using jQuery 3.4.1 and have tested this.

 $("#mydiv").delay(5000).show(200); // a 5 second delay before the 200 microseconds animation effect from hidden to visible is triggered.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文