jQuery:停止在多个滚动上重复动画?
我在停止动画时遇到问题…如果我将链接翻转5次以显示一个框并将其关闭..“显示”效果会发生5次…当我关闭它时,我只希望它显示一次 基本上,它似乎陷入了一个循环 你知道如何停止多个实例吗jQuery:停止在多个滚动上重复动画?,jquery,jquery-animate,Jquery,Jquery Animate,我在停止动画时遇到问题…如果我将链接翻转5次以显示一个框并将其关闭..“显示”效果会发生5次…当我关闭它时,我只希望它显示一次 基本上,它似乎陷入了一个循环 你知道如何停止多个实例吗 jQuery(document).ready(function(){ jQuery('.ttip').hover( function() { var offset = jQuery(this).offset(); console.log(off
jQuery(document).ready(function(){
jQuery('.ttip').hover(
function() {
var offset = jQuery(this).offset();
console.log(offset)
var width = jQuery(this).outerWidth();
var tooltipId = jQuery(this).attr("rel");
jQuery('#tooltip-container').empty().load('tooltips.html' + tooltipId).fadeIn(500);
jQuery('#tooltip-container').css({top:offset.top, left:offset.left + width + 10}).show();
},
function() {
jQuery('#tooltip-container').fadeOut(500);
});
});
您应该使用stop(true)
请参见如所述,使用您的代码强制动画跳转到结尾并停止(true),如以下示例所示:
jQuery(document).ready(function(){
jQuery('.ttip').hover(
function() {
var offset = jQuery(this).offset();
console.log(offset)
var width = jQuery(this).outerWidth();
var tooltipId = jQuery(this).attr("rel");
jQuery('#tooltip-container').empty().load('tooltips.html' + tooltipId).stop(true).fadeIn(500);
jQuery('#tooltip-container').css({top:offset.top, left:offset.left + width + 10}).show();
},
function() {
jQuery('#tooltip-container').stop(true).fadeOut(500);
});
});