1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
$(window).scroll(
function
(){
var
sc=$(window).scrollTop();
var
rwidth=$(window).width()+$(document).scrollLeft();
var
rheight=$(window).height()+$(document).scrollTop();
if
(sc > 800){
$(
"#goTop"
).css(
"display"
,
"block"
);
var
_width = $(
".progress"
).width() + $(
".progress"
).offset().left +110 ;
$(
"#goTop"
).css(
"right"
,(rwidth-_width)+
"px"
);
}
else
{
$(
"#goTop"
).css(
"display"
,
"none"
);
}
});
$(
"#goTop"
).click(
function
(){
$(
'body,html'
).animate({scrollTop:0},300);
});
|
1
|
<
div
id
=
"goTop"
class
=
"goTop"
></
div
>
|
1
2
3
4
5
6
7
8
9
10
11
|
.goTop
{
background
:
url
(images/return-
top
.png)
no-repeat
;
height
:
32px
;
width
:
32px
;
position
:
fixed
;
bottom
:
20px
;
right
:
0
;
display
:
none
;
cursor
:
pointer
;
}
|
本文转自 爱笑嘚蛋蛋 51CTO博客,原文链接:http://blog.51cto.com/dd118/1839575,如需转载请自行联系原作者