Created
May 22, 2015 11:58
-
-
Save Korveld/18c45d4bb03d286004ca to your computer and use it in GitHub Desktop.
Scroll to top of the page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(window).scroll(function () { | |
if ($(this).scrollTop() > 150) { | |
$('.scroll-top').fadeIn(400); | |
} | |
else { | |
$('.scroll-top').fadeOut(400); | |
} | |
}); | |
$('.scroll-top').click(function () { | |
$('body, html').animate({ | |
scrollTop: 0 | |
}, 800); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment