jQuery animation only working in IE

荒凉一梦 提交于 2019-12-02 13:50:08

问题


I have a very simple animation, were I have a tab at the side of the screen and if you click it, it will increase size. But it´s only working on IE, here is the code:

<script> 
$(function(){
  $("#a-tab > *").focusin(function(){
    $("#a-tab").animate({width:'320px'});
  });
  $("#a-tab > *").focusout(function(){
    $("#a-tab").animate({width:'10px'});
  });
});
</script>

It has to be #a-tab > * because of the inside content

Were is the problema, how can I make it compatible with Chrome, Firefox, etc.


回答1:


U can try sumthin like this:

<script> 
$(function(){
  $("#a-tab > *").focusin(function(){
    $("#a-tab").stop().animate({width:'320px'});
  });
  $("#a-tab > *").focusout(function(){
    $("#a-tab").stop().animate({width:'10px'});
  });
});
</script>

Just add .stop() before .animate(). I hope that works for u :)



来源:https://stackoverflow.com/questions/24588821/jquery-animation-only-working-in-ie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!