scrollTop在Firefox和IE上不起作用?

时间:2012-11-15 12:26:49

标签: jquery firefox google-chrome cross-browser scroll

我有以下代码,可以正常使用chrome。

然而,它不适用于Firefox和IE。没有任何事情发生。

 $("body").animate({scrollTop:$(this).offset().top},800);

所以我可以问我应该为firefox和IE编写什么?

感谢。

3 个答案:

答案 0 :(得分:35)

尝试使用

$('body,html').animate({scrollTop:$(this).offset().top},800);

而不是

$("body").animate({scrollTop:$(this).offset().top},800);

答案 1 :(得分:1)

试试这个。

document.getElementsByTagName('body')[0].clientHeight

答案 2 :(得分:0)

$(body).scrollTop($(this)[0].scrollHeight);
  

你使用这段代码,我认为它可以在IE和Firefox中正常使用

相关问题