// ===== Scroll to Top ==== $(window).scroll(function() { if ($(this).scrollTop() >= 50) { // If page is scrolled more than 50px $(".scrollToTop").fadeIn(200); // Fade in the arrow } else { $(".scrollToTop").fadeOut(200); // Else fade out the arrow } }); $(".scrollToTop").click(function() { // When arrow is clicked $("html").animate( { scrollTop: 0 // Scroll to top of body }, 500 ); });