Created
September 25, 2015 02:06
-
-
Save BryanBarrera/9b6d9d86c460595c59f7 to your computer and use it in GitHub Desktop.
Scroll to the top of the page after certain amount of pixels
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
// Scroll To Top | |
jQuery("a[href='#top']").click(function () { | |
jQuery("html, body").animate({ | |
scrollTop: 0 | |
}, "slow"); | |
return false; | |
}); | |
// hide button | |
jQuery('.elementBtn').hide(); | |
// after 200 pixels show if, else hide/fadeout | |
jQuery(window).scroll(function () { | |
if (jQuery(this).scrollTop() > 200) { | |
jQuery('.elementBtn').fadeIn(); | |
} else { | |
jQuery('.elementBtn').fadeOut(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment