Skip to content

Instantly share code, notes, and snippets.

@nafilimonov
Last active December 22, 2017 05:23
Show Gist options
  • Save nafilimonov/ed28f2093cc08524eef0e7503b735897 to your computer and use it in GitHub Desktop.
Save nafilimonov/ed28f2093cc08524eef0e7503b735897 to your computer and use it in GitHub Desktop.
JS. Кнопка вверх
<a id="go-to-top" href="#" class="go-to-top" role="button" title="Вверх">
<i class="fa fa-chevron-up" aria-hidden="true"></i>
</a>
$(window).scroll(function() {
// Высота проявления кнопки
if ($(this).scrollTop() > 100) {
$('#go-to-top').fadeIn();
} else {
$('#go-to-top').fadeOut();
}
});
$('#go-to-top').click(function() {
$('body,html').animate({scrollTop: 0}, 2000);
return false;
});
.go-to-top {
cursor: pointer;
display: none;
position: fixed;
bottom: 15px;
right: 15px;
z-index: 10;
}
@nafilimonov
Copy link
Author

Для иконки используется http://fontawesome.io/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment