Skip to content

Instantly share code, notes, and snippets.

@motorcitymobi
Created January 22, 2013 18:34
Show Gist options
  • Save motorcitymobi/4597017 to your computer and use it in GitHub Desktop.
Save motorcitymobi/4597017 to your computer and use it in GitHub Desktop.
(JS) - Scroll to Top
/*-----------------------------------------------------------------------------------*/
/* Jquery Scroll to top
/*-----------------------------------------------------------------------------------*/
jQuery('.top_scroll a').click(function(){
jQuery(this).stop().animate({opacity: '0'}, 200 ,function(){
jQuery('html, body').animate({scrollTop: '0'} ,600,function(){
jQuery('.top_scroll a').stop().animate({opacity: '1'});
});
});
return false;
});
jQuery(window).scroll(function () {
if (jQuery(this).scrollTop() > 200) {
jQuery('a[href=#top]').fadeIn();
} else {
jQuery('a[href=#top]').fadeOut();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment