ant
ant

Reputation: 22948

javascript scroll back to the top

how can I get this scroll back to the top neat thing from this link , just scroll down a bit, you'll see in the bottom right icon(top pointer) that scrolls back to the top on click. Thank you

Upvotes: 1

Views: 3842

Answers (2)

Dominic Rodger
Dominic Rodger

Reputation: 99751

In jQuery:

$(document).ready(function() {

    $('a[href=#top]').click(function(){
        $('html, body').animate({scrollTop:0}, 'slow');
        return false;
    });

});

You can then make links like this:

<a href="#top" title="Scroll back to the top">Back to the top</a>

Upvotes: 4

Bloeper
Bloeper

Reputation: 357

You can find the script here: http://www.javascriptkit.com/jkincludes/scrolltopcontrol.js

Although you need to use jquery for this script to work.

Upvotes: 1

Related Questions