Instantly share code, notes, and snippets.

Embed
What would you like to do?
$(".scroll-top-box").hide();
$(window).scroll(function (){
if ($(this).scrollTop() > 500){
$(".scroll-top-box").fadeIn();
} else{
$(".scroll-top-box").fadeOut();
}
});
$(".scroll-top-box").on("click", function(){
$('html, body').animate({scrollTop:0}, 'slow');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment