.stop()不能与悬停选择器一起工作

.stop() doesn't work with hover selector

本文关键字:选择器 一起 工作 悬停 不能 stop      更新时间:2023-09-26

这是我的代码:

$(function(){
  $("#deals ul li ul").hover(function(){
     $(this).stop().find(".trans").fadeIn("fast");
     $(this).stop().find(".text").fadeIn("fast");
     return false;
  },function(){
    $(this).find(".trans").fadeOut("fast");
    $(this).find(".text").fadeOut("fast");
  });
  return false;
});

当你快速悬停几次时,它会每秒加载这些动作,stop()应该会让它停止,但它在这里不起作用,任何想法都会受到赞赏。

.stop()需要位于潜在的动画元素上。

你的ul没有收到动画,所以它对.stop()没有任何好处。这是.trans.text元素的动画

$(function(){
  $("#deals ul li ul").hover(function(){
     $(this).find(".trans").stop().fadeIn("fast");
     $(this).find(".text").stop().fadeIn("fast");
     return false;
  },function(){
    $(this).find(".trans").fadeOut("fast");
    $(this).find(".text").fadeOut("fast");
  });
  return false;
});