国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

jQuery實現(xiàn)返回頂部按鈕和scroll滾動功能[帶動畫效果]

2019-11-19 16:10:23
字體:
供稿:網(wǎng)友

jQuery腳本:

 <script type="text/javascript">     $(function() {       var scrollDiv = document.createElement('div');       $(scrollDiv).attr('id', 'toTop').html('^ 返回頂部').appendTo('body');       $(window).scroll(function() {         if ($(this).scrollTop() != 0) {           $('#toTop').fadeIn();         } else {           $('#toTop').fadeOut();         }       });       $('#toTop').click(function() {         $('body,html').animate({ scrollTop: 0 }, 800);       })     });   </script>

CSS樣式:

<style type="text/css">     #toTop {       width: 100px;       z-index: 10;       border: 1px solid #333;       background: #121212;       text-align: center;      padding: 5px;      position: fixed;       bottom: 0px;       right: 0px;       cursor: pointer;      display: none;      color: #fff;       text-transform: lowercase;       font-size: 0.9em; }  </style>

帶有iframe框架的滾動操作:

<script type="text/javascript"> <!--     $().ready(function() {       $('<div id="return_old_tips" class="btn_return_old" style="position:' + ($.browser.msie ? "absolute" : "fixed") + ';" onclick="return_old({$feedback_flag},/'{$current_url}/')">返回舊版</div>').appendTo($("body"));       if ($.browser.msie) {        $("#return_old_tips").css("top", 200);      }      if ($.browser.msie) {        top.document.body.onscroll = function() {          var f = 200 + (top.document.documentElement.scrollTop || top.document.body.scrollTop);          if (f > parseInt($("body").height(), 10)) {            f = parseInt($("body").height(), 10);          }           $("#return_old_tips").css({            top: f,            left: 0           });        }         top.document.body.onresize = top.document.body.onscroll;      } else {        $(window.parent.document).scroll(function() {           var f = 200 + (top.document.documentElement.scrollTop || top.document.body.scrollTop);          if (f > parseInt($("body").height(), 10)) {            f = parseInt($("body").height(), 10);          }          $("#return_old_tips").css({            top: f,             left: 0           });        }).resize(function() {           var f = 200 + (top.document.documentElement.scrollTop || top.document.body.scrollTop);           if (f > parseInt($("body").height(), 10)) {            f = parseInt($("body").height(), 10);          }          $("#return_old_tips").css({            top: f,             left: 0           });         });       }     }); //-->   </script>

以上所述是小編給大家介紹的jQuery實現(xiàn)返回頂部按鈕和scroll滾動功能[帶動畫效果],希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對武林網(wǎng)網(wǎng)站的支持!

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 河北区| 邵东县| 蓬溪县| 南京市| 高雄市| 邢台县| 红桥区| 石台县| 炉霍县| 三原县| 南川市| 定日县| 平谷区| 会宁县| 海伦市| 丹阳市| 南川市| 长春市| 黄龙县| 广宁县| 吉安县| 尚义县| 汕尾市| 侯马市| 揭西县| 紫云| 新沂市| 资溪县| 东兰县| 泾源县| 托里县| 子洲县| 民乐县| 无极县| 黔南| 枣庄市| 夹江县| 黄陵县| 外汇| 东山县| 大埔县|