Skip to content

Instantly share code, notes, and snippets.

@andreyshr
Last active September 16, 2017 10:04
Show Gist options
  • Save andreyshr/83eaee5aac61609b798d10e6c797b89a to your computer and use it in GitHub Desktop.
Save andreyshr/83eaee5aac61609b798d10e6c797b89a to your computer and use it in GitHub Desktop.
topButton
<script>
$(function() {
$(window).scroll(function() {
if ($(this).scrollTop() != 0) {
$('#toTop').fadeIn();
} else {
$('#toTop').fadeOut();
}
});
$('#toTop').click(function() {
$('body,html').animate({
scrollTop: 0
}, 800);
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment