最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

jquery實(shí)現(xiàn)頁面常用的返回頂部效果

 更新時(shí)間:2016年03月04日 10:05:01   投稿:lijiao  
這篇文章主要為大家詳細(xì)介紹了jquery實(shí)現(xiàn)頁面常用的返回頂部效果代碼,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了jquery實(shí)現(xiàn)返回頂部效果的全部代碼,供大家參考,具體內(nèi)容如下

效果圖:

實(shí)現(xiàn)代碼:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>返回頂部</title>
  <style type="text/css">
     *{
       margin: 0;
       padding: 0;
     }
     .wrap{
       height: 2000px;
     }
     .gotop{
       display: block;
       width: 32px;
       height: 32px;
       background-color: red;
       text-align: center;
       text-decoration: none;
       font-size: 14px;
       font-weight: bold;
       color: white;
       line-height: 32px;
       position: fixed;
       right:50px;
       bottom:50px; 
       opacity: 0;
       /*top: 500px;*/
     }
  </style>
</head>
<body>
   <div class="wrap">
       <a href="###" class="gotop">TOP</a>
   </div>
   <script type="text/javascript" src="jquery-1.11.3.min.js"></script>
   <script type="text/javascript">
    $(function(){
         // 當(dāng)滾動條滾動大于200時(shí)出現(xiàn),未大于,消失
         $(window).scroll(function(){
           if($(document).scrollTop()<200){
             // alert("kk");
             $(".gotop").stop().animate({
               
                 opacity: 0
                 
             },1000)
           }
           else{
             $(".gotop").show().stop().animate({
                 
                 opacity: 1
                 
             },1000)
           }
        })
       // 返回頂部
       $(".gotop").on("click",function(){
          $("html body").animate({
             scrollTop:0
          },1000)
       })
    })
   </script>
</body>
</html>

希望本文所述對大家學(xué)習(xí)javascript程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評論

内黄县| 贵州省| 沧源| 修武县| 榆林市| 扶沟县| 安宁市| 交城县| 监利县| 永年县| 辽中县| 齐齐哈尔市| 鄄城县| 涪陵区| 蒲城县| 黑龙江省| 屏南县| 桂阳县| 龙州县| 桂林市| 通江县| 美姑县| 庄河市| 拉孜县| 红原县| 青田县| 五寨县| 镇原县| 日土县| 博兴县| 肇州县| 长治县| 华坪县| 渝中区| 肥东县| 灵山县| 洱源县| 民权县| 论坛| 平远县| 依兰县|