<!------------傳回頂部----------->
<div id="tbox">
<a id="gotop" href="javascript:void(0)">
<div>回到頂部</div>
</a>
</div>
<script type="text/javascript">
$(document).ready(function(){
/*傳回頂部*/
$('#tbox').hide();
$(window).scroll(function () {
if ($(window).scrolltop() > 300) {
$('#tbox').fadein(400);//當滑動欄向下滑動時,按鈕漸現的時間
} else {
$('#tbox').fadeout(0);//當頁面回到頂部第一屏時,按鈕漸隐的時間
}
});
$('#tbox').click(function () {
$('html,body').animate({
scrolltop : '0px'
}, 300);//傳回頂部所用的時間 傳回頂部也可調用goto()函數
function goto(selector){
$.scrollto ( selector , 1000);
</script>
/*------------傳回頂部css樣式-----------*/
#tbox { width: 32px; height: 32px; padding: 8px; border: 1px solid #eee; background: #f8f8f8 url(img/jt.png) no-repeat center; position: fixed; right: 15px; bottom: 100px; font-size:12px;text-align:center; cursor:pointer;}
#tbox div{ color:#000; display:none; background: #f8f8f8; line-height:18px;}
#tbox:hover div{ display:block;}