您好,我想问一下document.body.scrollTop如果想改成获取html中与一个对象的高为100时再显示div应该怎么写呢
<script>
window.onscroll = function() {scrollFunction()};
function scrollFunction() {console.log(121);
if (document.body.scrollTop > 1000 || document.documentElement.scrollTop > 1000 ) {
document.getElementById("backtoTop").style.display = "block";
document.getElementById("mobile-bottom-div").style.display = "flex";
} else {
document.getElementById("backtoTop").style.display = "none";
document.getElementById("mobile-bottom-div").style.display = "none";
}
}
function topFunction() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}
</script>