简体   繁体   English

jQuery show()被多次调用

[英]jQuery show() called multiple times

I have a 3 * 3 photo collage and want the corresponding text summary of the photo show up if the photo is moused over. 我有一个3 * 3的照片拼贴,如果将鼠标悬停在照片上,则希望显示照片的相应文本摘要。 The text summary is contained in a div with id summary-container.That being said, the previous text summary will be replaced by the current text with a slide animation effect. 文本摘要包含在id为summary-container的div中,也就是说,先前的文本摘要将被具有幻灯片动画效果的当前文本替换。 Below is the piece of javascript codes. 以下是一段JavaScript代码。

$('#photo-collage').find('.span4').hover(function(){  
      $('#summary-container').fadeOut();
      $('#summary-container').show('slide',{direction: 'left'},1000);
      $('#summary-container').load(url,data);
},function(){});

It works well if I hover over from one photo to the other. 如果我从一张照片移到另一张照片,效果很好。 But the problem is, ex, if I hover over from photo 1 to photo 4 while crossing photo 2 and photo 3, the show() function is called two more times. 但是问题是,例如,如果我在越过照片2和照片3时从照片1悬停在照片4上,则show()函数会再调用两次。 So there are two more slide animations, which is not necessary. 因此,还有两个幻灯片动画,这不是必需的。

How should I adjust my codes to solve this problem?Thanks 我应该如何调整代码以解决此问题?

Try 尝试

$("#summary-container").clearQueue().stop();

to clear the animation-queue. 清除动画队列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM