13

I have below code which works fine in chrome.

However, it does not work on firefox and also IE. Nothing happens.

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

So may i ask what i should write for firefox and IE??

Thanks.

kikkpunk
  • 1,287
  • 5
  • 22
  • 34

3 Answers3

36

try using

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

instead of

$("body").animate({scrollTop:$(this).offset().top},800);
rahul
  • 7,573
  • 7
  • 39
  • 53
  • 1
    This fixed a similar problem that I was having but now the script will not work in Chrome... >_ – Stephen__T Dec 18 '12 at 14:16
  • Note this will only work with `.animate()`, not with regular `.scrollTop()`: the former animates the `scrollTop` property of each elements in the set, but the latter will set the `scrollTop` value for the first element in the set. – Tom McKenzie Aug 19 '14 at 02:47
1

try this.

document.getElementsByTagName('body')[0].clientHeight
c-sharp
  • 573
  • 1
  • 9
  • 25
0
$(body).scrollTop($(this)[0].scrollHeight);

you use this code ,i think it will work properly in IE and Firefox

frooty
  • 202
  • 1
  • 2
  • 11