The following works in Chrome / FF etc...
$('body').animate({scrollTop : 0}, 0);
However, in IE 7, it doesn't do anything.
Is there an alternative?
EDIT As pointed out by many, it is better to use:
$('body, html').animate({scrollTop : 0}, 0);
$('body, html').animate({scrollTop : 0}, 0);
in IE8, i use $(document).scrollTop()
to get the scrollTop property, $('body').scrollTop()
or $('html').scrollTop()
will always return 0.
Maybe you can use
$(document).animate({scrollTop: 0}, 0);
$('html,body').animate({scrollTop: 0}, 0);
to make it works on all browser.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With