Last active
September 6, 2019 09:51
-
-
Save ntnyq/16bf8eb9c322b9f393737ebad752729f to your computer and use it in GitHub Desktop.
[Jqery Utils] #jQuery #Utils
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
;(function ($) { | |
var $backToTop = $('#back-to-top'); | |
$(window).scroll(function(e) { | |
if ($(window).scrollTop() >= 100) { | |
$backToTop.fadeIn(300); | |
} else { | |
$backToTop.fadeOut(300); | |
} | |
}); | |
$backToTop.click(function(e) { | |
$('html, body').animate({ | |
scrollTop: '0px' | |
}, 800); | |
e.preventDefault(); | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment