backtotop = document.getElementById("backtotop"); var ScrollFunc = function () { var y = window.scrollY; if (y >= 400) { backtotop.className = "fixed show" } else { backtotop.className = "fixed hide" } }; window.addEventListener("scroll", ScrollFunc); function topFunction() { document.body.scrollTop = 0; document.documentElement.scrollTop = 0; }