---
title: "页面回到顶部连接"
author: "guobinperfect"
date: "2011-05-01T09:51:14Z"
tags: []
categories: ["Web前端"]
slug: "untitled"
draft: false
lastmod: "2011-05-01T09:51:14Z"
id: 1025659
url: "https://guobinperfect.iteye.com/blog/1025659"
---

东西很简单，还是利用jQuery，直接代码：

html代码，一般放在footer.php里：

<a href="#" id="top"> 返 回 顶 部 </a>

CSS代码，使用了fixed让对象固定于浏览器窗口：

#top{position:fixed;bottom:0;right:10px;}

jQuery代码，注意正常使用的几个条件：

$('#top').click(function(){$('html,body').animate({scrollTop: '0px'}, 800);return false;});