<!DOCTYPE html><html lang="en"><head> ???<meta charset="UTF-8"> ???<title>返回顶部</title> ???<script src="scripts/jquery-1.7.1.min.js"></script></head><body><script type="text/javascript"> $(function(){var toppos = 0;$(".back_top_index").hide();$(document).scroll( ?function(){ ???toppos=$(document).scrollTop(); ???var oClient =$(window).height();//当前窗口可视区域高度 ???if(toppos>oClient){ ?????$(".back_top_index").fadeIn(); ?????}else if(toppos==0){ ?????$(".back_top_index").fadeOut(); ????} ?})$(".back_top_index").click(function(){ ???$("html,body").animate({scrollTop:0}) ?}) ??})</script> <div style="height:2000px;">3423424</div><div class="back_top_index">1</div><style>.back_top_index{width: 50px;height: 50px;position: fixed;bottom: 10px;right: 10px;background-color: red;}</style></body></html>
jQuery 返回顶部效果
原文地址:http://www.cnblogs.com/arealy/p/7765537.html