-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoTop.js
More file actions
34 lines (34 loc) · 1002 Bytes
/
Copy pathtoTop.js
File metadata and controls
34 lines (34 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
jQuery(document).ready(function ($) {
if ($("meta[name=toTop]").attr("content") == "true") {
$("<div id='toTop'><img src='toTop.png'></div>").appendTo('body');
$("#toTop").css({
width: '50px',
height: '50px',
bottom: '70px',
right: '10px',
position: 'fixed',
cursor: 'pointer',
zIndex: '999999',
});
if ($(this).scrollTop() == 0) {
$("#toTop").hide();
}
$(window).scroll(function (event) {
/* Act on the event */
if ($(this).scrollTop() == 0) {
$("#toTop").hide();
}
if ($(this).scrollTop() != 0) {
$("#toTop").show();
}
});
$("#toTop").click(function (event) {
/* Act on the event */
$("html,body").animate({
scrollTop: "0px"
},
666
)
});
}
});