$jq(function () { // Bind to scroll. $(window).scroll(function() { //Display or hide scroll to top button. if ($(this).scrollTop() > 100) { $('#scroll-top-link').fadeIn(); } else { $('#scroll-top-link').fadeOut(); } }); // Function for scrolling to top. $('#scroll-top-link').click(function(e) { $("html, body").animate({ scrollTop: 0 }, 600); return false; }); });