Skip to content

Instantly share code, notes, and snippets.

@zaurmag
Last active August 7, 2016 18:17
Show Gist options
  • Save zaurmag/34c5fb5099fcd9389365b61ac62c7fee to your computer and use it in GitHub Desktop.
Save zaurmag/34c5fb5099fcd9389365b61ac62c7fee to your computer and use it in GitHub Desktop.
Наверх
// ======= Go Top =======
(function($) {
jQuery.fn.scrollToTop = function() {
$(this).hide().removeAttr("href");
if ($(window).scrollTop() != "0") {
$(this).fadeIn("slow")
}
var scrollDiv = $(this);
$(window).scroll(function() {
if ($(window).scrollTop() == "0") {
$(scrollDiv).fadeOut("slow")
} else {
$(scrollDiv).fadeIn("slow")
}
});
$(this).click(function() {
$("html, body").animate({
scrollTop: 0
}, "slow")
});
}
})(jQuery);
// ======= Init Go Top =======
$('.go_top_link').scrollToTop();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment