【www.bbyears.com--jquery】
top.js代码
代码如下var IMYUAN;
IMYUAN || (IMYUAN = {});
(function(a) {
a.fn.extend({
returntop: function() {
if (this[0]) { var b = this.click(function() { a("html, body").animate({ scrollTop: 0 },
120) }),
c = null; a(window).bind("scroll", function() {
var d = a(document).scrollTop(),
e = a(window).height();
0 < d ? b.css("bottom", "200px") : b.css("bottom", "-200px"); a.isIE6() && (b.hide(), clearTimeout(c), c = setTimeout(function() {
b.show();
clearTimeout(c)
},
1E3), b.css("top", d + e - 125)) })
}
}
})
})
(jQuery); (function(a) {
a("body")("javascript:;">");
})
(function() {
$("#returnTop").returntop() });
实例
代码如下
回到顶部
<script src="js/jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="js/top.js" type="text/javascript"></script>
<script language="javascript">
for(i=0;i<50;i++){
document.write(i+"
");
}
</script>