jQuery 动画在 chrome/safari/ie 中不起作用
Posted
技术标签:
【中文标题】jQuery 动画在 chrome/safari/ie 中不起作用【英文标题】:jQuery animate not working in 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? 【参考方案1】:我确实遇到了这个问题...我正在制作动画的div
有position:absolute
。为我解决的问题是在 css 中设置 top
和 left
。一旦我将它们添加到宾果游戏中,它就起作用了!
【讨论】:
【参考方案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);
);
)
【讨论】:
以上是关于jQuery 动画在 chrome/safari/ie 中不起作用的主要内容,如果未能解决你的问题,请参考以下文章
jQuery .animate( 'width' : 'show' ) 在 Chrome/Safari 中无法正常工作?
jQuery 动画在 Internet Explorer 中不起作用/行为异常
Chrome, Safari 中的 JQuery .animate() != FF, IE, Opera
jquery or not / Cross Browser Compatible iframe resize (IE, Chrome, Safari, Firefox)