Created
October 19, 2017 03:38
-
-
Save kentatogashi/c041750d34cffe40999046b1e55313ac to your computer and use it in GitHub Desktop.
役に立ちそうなJQスニペット
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
$(document).ready(function(){ | |
//Check to see if the window is top if not then display button | |
$(window).scroll(function(){ | |
if ($(this).scrollTop() > 500) { | |
$('.scrollToTop').fadeIn(); | |
} else { | |
$('.scrollToTop').fadeOut(); | |
} | |
}); | |
//Click event to scroll to top | |
$('.scrollToTop').click(function(){ | |
$('html, body').animate({scrollTop : 0},800); | |
return false; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment