参考:关于jquery 怎样让 animate不多次执行呢

当click方法里面,执行animate时,然后点击的比较频繁,那么animate()的动画也会比较多次滚动。

如:

function scrollToRight(){
     $(".trainer-ul-box").animate({left:"-=10px"});    
}

参考CSDN中的方法之后,修改为:

1 function scrollToRight(){
2   if($(".trainer-ul-box:animated").length==0){
3      $(".trainer-ul-box").animate({left:"-=10px"});
4   }
5 }

 

.trainer-ul-box 为动画元素的选择器

相关文章:

  • 2021-09-05
  • 2022-12-23
  • 2022-12-23
  • 2021-10-21
  • 2021-07-07
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-02
  • 2021-05-27
  • 2021-10-01
  • 2021-09-18
  • 2022-12-23
  • 2021-10-28
  • 2022-12-23
相关资源
相似解决方案