Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scrollTop doesn't work on firefox and IE? [duplicate]

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.

like image 681
kikkpunk Avatar asked Nov 15 '12 12:11

kikkpunk


2 Answers

try using

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

instead of

$("body").animate({scrollTop:$(this).offset().top},800);
like image 110
rahul Avatar answered Sep 29 '22 15:09

rahul


try this.

document.getElementsByTagName('body')[0].clientHeight
like image 22
c-sharp Avatar answered Sep 29 '22 16:09

c-sharp