YesTop 只需一句 jQuery 程式碼即可實現返回頂部功能,使用相當簡便。
效果體驗:https://hovertree.com/texiao/yestop/
使用方法:只需引用 jQuery 函式庫與 YesTop 外掛(jquery.yestop.js),再一行程式碼就能實現返回頂部。
引用程式碼:
<script src="https://hovertree.com/ziyuan/jquery/jquery-1.11.3.min.js"></script>
<script src="https://hovertree.com/texiao/yestop/inc/jquery.yestop.js"></script>
使用程式碼:
<script>
$(document).ready(function () { $.fn.yestop(); });
</script>
也就是這一句:
$.fn.yestop();
當然還有進階設定,例如更換圖片、把圖示設為圓形、調整位置、設定時間等等。例如:
$.fn.yestop({
"yes_image": "https://hovertree.com/texiao/yestop/inc/yestoprocket.png"
, "yes_width": "48px", "yes_height": "125px", "yes_time": 200
, "yes_bottom":"20px", "yes_right":"10px"
});
更多細節請參考其他 Demo。
以下為完整程式碼,存成 HTML 檔即可體驗效果:
<!DOCTYPE html>
<html>
<head><meta charset="UTF-8">
<title>YesTop - HoverTree</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="https://hovertree.com/ziyuan/jquery/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="https://hovertree.com/texiao/yestop/inc/jquery.yestop.js"></script>
<style>
body {
margin: 0px; font-family:Arial
} a {color:blue}
</style>
</head>
<body>
<div style="text-align:center;width:100%;margin:0px auto;">
<h1>YesTop</h1>
A jQuery Plugin<br />
<a href="https://hovertree.com/texiao/yestop/">Demo 1</a> <a href="https://hovertree.com/texiao/yestop/demo2.htm">Demo 2</a> <a href="https://hovertree.com/texiao/yestop/demo3.htm">Demo 3</a>
<a href="https://hovertree.com/texiao/yestop/demo4.htm">Demo 4</a> <a href="https://hovertree.com/h/bjaf/topimage.htm">Images</a>
</div>
<div style="height: 360px;background-color: #66FF66;"></div>
<div style="width:100%;text-align:center;height:200px">© hovertree.com</div>
<div style="height: 200px; visibility: visible; background-color: Olive"></div>
<div style="height:200px;background-color:burlywood"></div>
<div style="height:200px;background-color:darkorchid"></div>
<div style="height: 200px; visibility: visible; background-color:gray"></div>
<div style="height:200px;background-color:blue"></div>
<div style="height:200px;background-color:red"></div>
<div style="height:200px;background-color:yellow"></div>
<div style="height:200px;background-color:yellowgreen"></div>
<div style="height:800px;background-color:white"></div>
<script type="text/javascript">
$(document).ready(function () { $.fn.yestop(); });
</script>
</body>
</html>