Skip to content

Instantly share code, notes, and snippets.

@coinso
Created June 13, 2017 08:00
Show Gist options
  • Save coinso/9b0074acdd4d5969c387aaacbd113e96 to your computer and use it in GitHub Desktop.
Save coinso/9b0074acdd4d5969c387aaacbd113e96 to your computer and use it in GitHub Desktop.
ScrollUp
<a href="#" class="scrollup" style="display: none;"><i class="fa fa-angle-up active"></i></a>
(function($){
$(window).scroll(function () {
if ($(this).scrollTop() > 100) {
$('.scrollup').fadeIn();
} else {
$('.scrollup').fadeOut();
}
});
$('.scrollup').click(function () {
$("html, body").animate({
scrollTop: 0
}, 1000);
return false;
});
})(jQuery);
.scrollup {
display: none;
position: fixed;
bottom: 15px;
right: 15px;
width: 50px;
height: 50px;
background: #fff;
outline: 0;
text-align: center;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment