基於jquery 360導航返回頂部代碼

來源:互聯網
上載者:User

top.js代碼

 代碼如下 複製代碼

var IMYUAN;  

IMYUAN || (IMYUAN = {});  
 
(function(a) {  
 
    a.fn.extend({  
        returntop: function() {  
            if (this[0]) {                   var b = this.click(function() {                       a("html, body").animate({                           scrollTop: 0                      },  
                    120)                   }),  
                c = null;                   a(window).bind("scroll",                   function() {  
                    var d = a(document).scrollTop(),  
                    e = a(window).height();  
                    0 < d ? b.css("bottom", "200px") : b.css("bottom", "-200px");                       a.isIE6() && (b.hide(), clearTimeout(c), c = setTimeout(function() {  
                        b.show();  
                        clearTimeout(c)  
                    },  
                    1E3), b.css("top", d + e - 125))                   })  
            }  
        }  
 
    })  
})  
 
(jQuery); (function(a) {  
 
    a("body")('<a class="close" href="javascript:;"></a>');    
})  
 
(function() {  
 
    $("#returnTop").returntop()   });  

執行個體

 代碼如下 複製代碼

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>360導航返回頂部特效代碼</title>
<link href="css/top.css" rel="stylesheet"  type="text/css"/>
</head>

<body style="text-align:center; height:1000px">
</head>

<a id="returnTop" href="javascript:;">回到頂部</a>
<script src="js/jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="js/top.js" type="text/javascript"></script>

<p>
    <script language="javascript">
for(i=0;i<50;i++){
 document.write(i+"<br />");
}
  </script>
</body>
</html>

友情提醒

jquery代碼各位同學可以自己到官方下載最新版本的,這裡只提供返回頂部代碼,我們把top.js儲存然後再調用即可實現。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.