本文介绍了删除隐藏延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(function($)
{
 $.fn.blink = function(options)
 {
  var defaults = { delay:5000 };
  var options = $.extend(defaults, options);

  return this.each(function()
  {
   var obj = $(this).find("img");
   setInterval(function()
   {
    if($(obj).css("display") == "block")
    {
     $(obj).fadeOut('slow');
    }
    else
    {
     $(obj).fadeIn('slow');
    }
   }, options.delay);
  });
 }
}(jQuery))

$('.blink').blink();

HTML:

<a href="#" class="blink">
    <img src="image.png" alt="some image" />
</a>

此脚本删除具有过渡效果的图像,然后将其显示回来。所以这里有两个步骤:1)隐藏,2)显示。

This script removes image with transition effect, and then shows it back. So here are two steps: 1) hide, 2) show.

每一步有5秒的延迟,它应该只在图像可见时。

如何从隐藏步骤中删除延迟?当图像不可见时,不应有任何延迟。

How do I remove delay from the hide step? There should not by any delay when image is unvisible.

提供代码

Code is available on JsFiddle

它是一个圆形脚本,一旦淡入/淡出完成,它应该再次启动。

Its a circle script, once fadeIn/Out is done, it should be started again.

谢谢。

推荐答案

要删除 fadeOut 之后的延迟,只需将调用链接起来按照自己的间隔调用它们:

To remove the delay after fadeOut, just chain the calls instead of calling them on their own interval:

$(obj).fadeOut('slow').fadeIn('slow');

我对代码进行了一些简化:

I made some simplifications to the code: http://jsfiddle.net/vcWDy/2/

这篇关于删除隐藏延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 15:09