一句jQuery代碼實現(xiàn)返回頂部效果(簡單實用)
使用方法:
只需引用jQuery庫和YesTop插件,然后一句代碼就可以實現(xiàn)返回頂部:
引用代碼:
<script type="text/javascript" src="http://hovertree.com/ziyuan/jquery/jquery-1.11.3.min.js"></script> <script type="text/javascript" src="http://hovertree.com/texiao/yestop/inc/jquery.yestop.js"></script>
使用代碼:
<script type="text/javascript"> $(document).ready(function () { $.fn.yestop(); }) </script>
也就是:
$.fn.yestop();
這句代碼就可以了。
當然還有高級的設(shè)置,如換圖片,設(shè)置圖標為圓形,設(shè)置位置,設(shè)置時間等等。詳情請查看其他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="http://hovertree.com/ziyuan/jquery/jquery-1.11.3.min.js"></script> <script type="text/javascript" src="http://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 >Demo 1</a> <a >Demo 2</a> <a >Demo 3</a> <a >Demo 4</a> <a >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>
以上就是本文的全部內(nèi)容,希望本文的內(nèi)容對大家的學習或者工作能帶來一定的幫助,同時也希望多多支持腳本之家!
相關(guān)文章
JqueryMobile動態(tài)生成listView并實現(xiàn)刷新的兩種方法
本篇文章主要是對JqueryMobile動態(tài)生成listView并實現(xiàn)刷新的兩種方法進行了介紹,需要的朋友可以過來參考下,希望對大家有所幫助2014-03-03jQuery 函數(shù)實例分析【函數(shù)聲明、函數(shù)表達式、匿名函數(shù)等】
這篇文章主要介紹了jQuery 函數(shù),結(jié)合實例形式分析了jquery函數(shù)聲明、函數(shù)表達式、匿名函數(shù)等相關(guān)使用技巧,需要的朋友可以參考下2020-05-05jQuery實現(xiàn)鼠標經(jīng)過彈出提示信息的地圖熱點效果
這篇文章主要介紹了jQuery實現(xiàn)鼠標經(jīng)過彈出提示信息的地圖熱點效果,涉及jquery鼠標事件及頁面元素樣式的動態(tài)操作技巧,非常具有實用價值,需要的朋友可以參考下2015-08-08JQuery移動頁面開發(fā)之屏幕方向改變與滾屏的實現(xiàn)
這篇文章主要介紹了JQuery移動頁面開發(fā)之隨屏幕方向改變與滾屏的實現(xiàn),通過相關(guān)兩個事件的添加來達到響應移動設(shè)備上操作的效果,需要的朋友可以參考下2015-12-12