[resolved] How to add a "Back To Top" button ? (4 posts)

  1. corentino
    Posted 3 years ago #

    Hi !

    I use Infinite Scroll on my website which has now over 250 articles and I would like to add a 'Back To Top' button so my readers won't have to scroll all the way up anymore !

    Can anyone give me some help ?


  2. deutschwulf
    Posted 3 years ago #

    I just hardcoded one into my website. The following snippet slides the button in when you scroll past 800px, and then when the button is clicked it rolls you back up to the top of the page.

                if ($(this).scrollTop() > 800) {
        				$('#scrolltotop').stop().animate({ right: '21px' });
    				else {
        			$('#scrolltotop').stop().animate({ right: '-42px' });
                $("html, body").animate({ scrollTop: 0 }, 500);
                return false;

    All you need to do is include that in the head of your site, and create a <div> with the id of #scrolltotop somewhere on your page (I created a position:fixed element. I recommend you do it that way.)

  3. benarobinson
    Posted 3 years ago #

  4. corentino
    Posted 3 years ago #

    Thanks benarobinson !
    It works fine on my site !

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Infinite-Scroll
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic