开发者

javascript scroll back to the top

开发者 https://www.devze.com 2022-12-10 20:13 出处:网络
how can I get this scroll back to the top neat thing from this link , just scroll down a bit, you\'ll see in t开发者_JS百科he bottom right icon(top pointer) that scrolls back to the top on click. Than

how can I get this scroll back to the top neat thing from this link , just scroll down a bit, you'll see in t开发者_JS百科he 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消