Skip to content

Instantly share code, notes, and snippets.

@RuslanAsadov
Last active December 2, 2018 11:45
Show Gist options
  • Save RuslanAsadov/624f1afd276d8ae932523f5f36c0aaf7 to your computer and use it in GitHub Desktop.
Save RuslanAsadov/624f1afd276d8ae932523f5f36c0aaf7 to your computer and use it in GitHub Desktop.
scrolltop.js
//start scrolltop
$(window).scroll(function() {
if ($(this).scrollTop() > $(this).height()) {
$('.scrolltop').addClass('active');
} else {
$('.scrolltop').removeClass('active');
}
});
$('.scrolltop').click(function() {
$('html, body').animate({scrollTop: 0}, 'slow', 'swing');
});
//close scrolltop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment