I have a page that when a certain event happens, I want the screen to automatically scroll back to the top.
I want the script to wait 2 seconds, and then it takes 2 seconds to scroll to the top of the page.
// Scroll to top
setTimeout(function(){
alert('scroll');
$('html, body').animate({scrollTop : 0}, 2000);
}, 2000);
I get the alert after 2 seconds, but the screen doesn't move.
Is there something wrong with my scrollTop
code?