简体   繁体   English

javascript滚动回到顶部

[英]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: 在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 您可以在以下位置找到脚本: http : //www.javascriptkit.com/jkincludes/scrolltopcontrol.js

Although you need to use jquery for this script to work. 尽管您需要使用jquery才能使此脚本正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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