Fade-in effect for a button when the user scrolls down and button comes into view and a fade-out effect when the user continue scrolls down and button goes out of view.
var scrollButton = $('#scrollButton');
scrollButton.css('opacity', '0');
$(window).scroll(function() {
var scrollPos = $(this).scrollTop();
if (scrollPos > 100) {
scrollButton.css('opacity', '1');
} else {
scrollButton.css('opacity', '0');
}
});
New contributor
Wayne Ng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.