Go to top of page using jQuery
2009 September 18
This one liner jQuery snippet will force your browser to go to the top of your page:
$( 'html, body' ).animate( { scrollTop: 0 }, 0 );
If you want to add some smooth scrolling:
$( 'html, body' ).animate( { scrollTop: 0 }, 'slow' );
hiya,
Do you have to add an element that the user can click on?
I ask because I have jQuery installed: jquery-1.3.2.min.js
..and javScript enabled.
I have other jQuery effects working on the same page.
I tried the following:
TOP
$(”h3″)
$(’html, body’).animate({ scrollTop: 0 }, ’slow’);
Do you know where I’m going wrong?
Many thanks,
Blockstopper