【发布时间】:2011-11-19 14:23:51
【问题描述】:
我的 jquery 动画代码在 IE 和 firefox 中运行良好,但在 Chrome 和 safari 中无法运行。有什么建议吗?
这是我的 jquery 动画代码
$('#menu ul li a').click(function (e) {
/* On a thumbnail click */
$('li.menuItem').removeClass('act').addClass('inact');
$(this).parent().addClass('act');
var pos = $(this).parent().prevAll().length; //.prevAll('.menuItem').length;
pos = pos - 1;
$('#slides').animate({ marginLeft: -positions[pos] + 'px' }, 450);
/* Start the sliding animation */
e.preventDefault();
/* Prevent the default action of the link */
});
【问题讨论】:
-
我在我的代码中使用 animate({"margin-left": "-350px"}) 而不是 marginLeft
-
marginLeft 在 IE 和 firefox 中运行良好。
-
margin-left 在 Firefox 中不起作用。没有检查其他浏览器。
标签: javascript jquery firefox google-chrome safari