window.onscroll = function() {scrollFunction()}; function scrollFunction() { let homeSection = document.getElementById("home"); let scrollTopBtn = document.getElementById("scrollTopBtn"); if (window.pageYOffset > 200) { scrollTopBtn.style.display = "block"; } else { scrollTopBtn.style.display = "none"; } } document.getElementById("scrollTopBtn").addEventListener('click', function() { document.body.scrollTop = 0; document.documentElement.scrollTop = 0; });