Here’s a useful snippet of reusable code to use jQuery to smoothly scroll to the top of the page. I first wrote it in response to a question on Stack Overflow. It finds any anchor with href equal to #top.
[javascript]
$("a[href=’#top’]").click(function(e) {
e.preventDefault();
$("html").animate({ scrollTop: 0 }, "slow");
});
[/javascript]