Jquery ScrollTop

发布时间:2020-04-11 06:06:26 作者:gkvalley
来源:网络 阅读:1082

use Jquery-1.4.4.min.js

<script src="../../Scripts/jquery-1.4.4.min.js" type="text/javascript"></script>

 

    Top.js:

$(document).ready(function () {

    var show_delay;

    var scroll_left = parseInt((document.body.offsetWidth - 960) / 2) + 961;

    $(".scroll").click(function () {

        document.documentElement.scrollTop = 0;

        document.body.scrollTop = 0;

    }); 

    $(window).resize(function () {

        scroll_left = parseInt((document.body.offsetWidth - 960) / 2) + 961;

        $(".scroll").css("left", scroll_left);

    }); reshow(scroll_left, show_delay);

});

function reshow(marign_l, show_d) {

    $(".scroll").css("left", marign_l);

    if ((document.documentElement.scrollTop + document.body.scrollTop) != 0) {

        $(".scroll").css("display", "block");

    }

    else { $(".scroll").css("display", "none"); }

    if (show_d) window.clearTimeout(show_d); 

     show_d = setTimeout("reshow()", 500); }

 


 

CSS:

 

<style type="text/css">

     .scroll{   bottom:100px;cursor:pointer; text-align:center;

                height:35px;width:35px;position:fixed;

                border:2px solid black; background-color:#dab766;}

</style>

Html:

 

<p>there is top....</p>

<div style=" height:980px;"></div>

<div class="scroll">Top</div>

 

 

推荐阅读:
  1. (JQuery学习笔记)利用jquery制作网页导航定位
  2. jquery回到页面顶部代码案例

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

it

上一篇:centos下安装、配置uWSGI+Nginx

下一篇:sql分组查询每组的第一条记录

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》