-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
32 lines (23 loc) · 899 Bytes
/
script.js
File metadata and controls
32 lines (23 loc) · 899 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
$(document).ready(function($){
$(this).on('click', 'a[href^="#"]', function () {
$('html, body').animate({
scrollTop: $('a[name="'+this.hash.slice(1)+'"]').offset().top
}, 1000 );
return false;
});
$('body').append('<a href="#" id="go-top" title="Вверх">Вверх</a>');
$.fn.scrollToTop = function() {
$(this).hide().removeAttr("href");
if ($(window).scrollTop() >= "250") $(this).fadeIn("slow");
var scrollDiv = $(this);
$(window).scroll(function() {
if ($(window).scrollTop() <= "250") {
$(scrollDiv).fadeOut("slow");
} else $(scrollDiv).fadeIn("slow");
});
$(this).click(function() {
$("html, body").animate({scrollTop: 0}, "slow")
});
};
$("#go-top").scrollToTop();
});