简体   繁体   中英

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

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>

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM