.scrollLeft()方法不起作用 [英] .scrollLeft() method not working
问题描述
我有一些jQuery脚本的页面。一切都很好,除了IE。我无法解决滚动问题的位置。
I have page with some jQuery scripts. Everything is fine except IE. I can't resolve where's the problem with scrolling.
整个页面是一个长水平页面。每当我更改PAGE(页面的标识号)时,web都应向左或向右滚动。以下是我处理上一个按钮操作的一些代码:
Whole page is one long horizontal page. Everytime when I change the PAGE (identifier number of page), web should scroll left or right. Here's some code of how I handle previous button action:
$('#previous').click(function() {
var width = $(window).width();
var leftOffset = $(document, window).scrollLeft();
var browser = get_browser();
hidePaging();
$((browser == "Firefox" || browser == "msie") ? "html" : "body").animate({
scrollLeft: page > 2 ? width * 2 : leftOffset - width
},
1000,
function () {
page = page > 2 ? 2 : page - 1;
console.log(page);
fixPagingAppearance();
}
);
});
我的问题是:为什么在IE浏览器中无法正常工作?!
My question is: "Why scroll in IE not working?!"
感谢您的回复。
推荐答案
我认为您应该使用 $( html,body)。动画({ - 您的代码 - })
而不是使用 $(html)
或 $(body)
。
I think you should use $("html,body").animate({--your code--})
instead of using either $("html")
or $("body")
.
替换此行:
var leftOffset = $(document,window).scrollLeft();
with
var leftOffset = $(document).scrollLeft();
。
参考:< a href =http://forum.jquery.com/topic/animate-scrollleft-get-problems-in-ie-and-ff =nofollow> http://forum.jquery.com/topic/ animate-scrollleft-get-problems-in-ie-and-ff
这篇关于.scrollLeft()方法不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!