jquery 回到顶部 回到底部

发布时间:2020-08-11 03:28:10 作者:彭票
来源:网络 阅读:1204

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

   <title></title>

   <script src="jquery-1.7.1.min.js"></script>

   <style type="text/css">

       body {

       font-size:12px;

       }

       #scroll {

       position:fixed; top:300px; right:100px;

       }


       .scrollItem {

       width:20px; height:70px;border:#e1e1e1 1px solid; cursor:pointer; text-align:center; padding-top:10px;

       }

   </style>

   <script type="text/javascript">

       $(function () {

           var speed = 1000;//滚动速度


           //回到顶部

           $("#toTop").click(function () {

               $("body").animate({ "scrollTop": 0 }, speed);

           });

           //回到底部

           var windowHeight = parseInt($("body").css("height"));//整个页面的高度

           $("#toBottom").click(function () {

               $("body").animate({ "scrollTop": windowHeight }, speed);

           });



       });

   </script>


</head>

<body>

   <div ></div>

   <p id="liuyan">这里是留言位置,回到这儿来额</p>

   <div ></div>

   <div id="scroll">

       <div class="scrollItem" id="toTop">回到顶部</div>

       <div class="scrollItem" id="toBottom">回到顶部</div>

   </div>

</body>

</html>


附件:http://down.51cto.com/data/2363984
推荐阅读:
  1. 如何用js和jQuery实现回到页面顶部功能
  2. Jquery编程基础

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

jquery 回到顶部 回到底部 ue j

上一篇:阿里架构师:带你快速理解微服务架构,理解微服务架构的核心

下一篇:神助攻or猪队友:靠AI“僚机”脱单到底有多难?

相关阅读

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

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