Skip to content

Instantly share code, notes, and snippets.

@jentanbernardus
Created February 8, 2013 03:48
Show Gist options
  • Save jentanbernardus/4736454 to your computer and use it in GitHub Desktop.
Save jentanbernardus/4736454 to your computer and use it in GitHub Desktop.
Simple jQuery Scroll To Top
$(document).ready(function(){
$("#go-to-top").hide();
$(function () {
$(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}, 800);
return false;
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment