Implementing a fade-in effect for a button as the user scrolls down and the button comes into view, along with a fade-out effect as the user continues scrolling down and the button goes out of view.
var fadeInButton = $('#fadeInButton');
fadeInButton.css('opacity', '0');
$(window).scroll(function() {
var scrollPosition = $(this).scrollTop();
if (scrollPosition > 100) {
fadeInButton.css('opacity', '1');
} else {
fadeInButton.css('opacity', '0');
}
});