【问题标题】:jQuery animate not working in chrome/safari/iejQuery 动画在 chrome/safari/ie 中不起作用
【发布时间】:2011-04-13 05:52:19
【问题描述】:

我已经编写了几行 jQuery 来根据鼠标移动为 div 向左/向右移动动画

 $(".galleryNav").mousemove(function(e){
  $("#status").html(e.pageX +', '+e.pageY);

  if(e.pageX > 1100 && e.pageX < 1170){
   $(".galleryNav").animate({marginLeft:"-60px"},{queue: false, duration: 450});
  }

  if(e.pageX > 410 && e.pageX < 465){
   $(".galleryNav").animate({marginLeft:"10px"},{queue: false, duration: 450});
  }
 });

它在 Firefox 中运行良好,但在 chrome、safari 或 IE 中没有任何反应。

有什么建议吗?

【问题讨论】:

  • 你用的是哪个版本的jQuery?

标签: jquery internet-explorer safari margin jquery-animate


【解决方案1】:

我确实遇到了这个问题...我正在制作动画的divposition:absolute。为我解决的问题是在 css 中设置 topleft。一旦我将它们添加到宾果游戏中,它就起作用了!

【讨论】:

    【解决方案2】:

    对我来说,它适用于 jQuery 1.4.2 + UI 8。 检查你的 CSS。

    【讨论】:

      【解决方案3】:

      在 chrome http://jsfiddle.net/x9eZY/ 中运行良好,也许问题出在其他地方?你有没有像这样将你的脚本封装在$(function(){}) 中:

      $(function(){
          $(".galleryNav").mousemove(function(e){
            $("#status").html(e.pageX +', '+e.pageY);
      
            if(e.pageX > 1100 && e.pageX < 1170){
             $(".galleryNav").animate({marginLeft:"-60px"},{queue: false, duration: 450});
            }
      
            if(e.pageX > 410 && e.pageX < 465){
             $(".galleryNav").animate({marginLeft:"10px"},{queue: false, duration: 450});
            }
          });
      })  
      ​
      

      【讨论】:

        猜你喜欢
        • 2011-02-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多