Go to top of page using jQuery

cdl_capture_2011-08-02-09_ 000

 

This one liner jQuery snippet will force your browser to go to the top of your page:

view sourceprint?

1.$( 'html, body' ).animate( { scrollTop: 0 }, 0 );

If you want to add some smooth scrolling:

view sourceprint?

1.$( 'html, body' ).animate( { scrollTop: 0 }, 'slow'

$("h3").click(function(){
          $(‘html, body’).animate({ scrollTop: 0 }, ‘slow’);
})

Leave a comment