Hi, I want to add a 'back-to-the-top' link that follow my article as I scroll down to read it... How can I do it? Any helpful link?

Thanks a lot, Robert

2 answers

This was chosen as the best answer

Check out the site I'm designing: Wild Birds Unlimited, Dublin CA and the corresponding startup jQuery script: http://www.wbudublin.com/new/jquery.startup.js

Maybe that should help get you started?

As you scroll down, the "Top" link pops out of the right hand side and follows you down and up the page until you're back near the top, then it pops out of sight.

The JavaScript is decently documented I think... and you can search the html for backToTop

Answered almost 9 years ago by Aric Evins
  • Great helpful answer and very attractive website as well! Doug almost 9 years ago
  • Thanks! Although it should be noted that in IE6, I couldn't get position: fixed to work (without a ton of headache), so I just excluded the feature from that browser and version explicitly. Aric Evins almost 9 years ago
  • Thanks Aric. I also find this in the web.. a list of solutions to pick and download... http://www.net-kit.com/7-scroll-to-top-jquery-solutions/ Robert A Henru almost 9 years ago

You really dont need an entire script for this.

You just need <a href="#top" id="toplink">Back to top</a>

Then for your css

#toplink {
display: block;
position: fixed;
right: 0;
top: 40px;
width: 100px;

And, if you want it to not be visible when you are at the top of the page

$(window).scroll() {

   if($(this).scrollTop() > 40)
    else $('#toplink').fadeOut('slow');

nb: i may have selected the wrong element for the .scroll event.

Answered over 8 years ago by Matthew Hailwood