1 window.addEventListener("scroll", function () { 2 if (document.body.scrollTop >= window.innerHeight) { 3 document.getElementById("top_back").style.display = "block"; 4 } else { 5 document.getElementById("top_back").style.display = "none"; 6 } 7 }
document.body.scrollTop---------------->document.documentElement.scrollTop
document.body.scrollTop在手机里其作用,但是document.documentElement.scrollTop不起作用