According to the first answer to the question at Stackoverflow, it can be known when element.innerHeight + element.scrollTop is greater than or equal to element.offsetHeight. Shouldn’t it be element.innerHeight + element.scrollTop is greater than or equal to element.scrollHeight? offsetHeight just includes the padding while calculating the visible height, what we want here is to find whether the scrolled height plus the visible height equals the total height, isn’t the total height given by scrollHeight?
According to the first answer to the question at Stackoverflow , it can be
Share
In general, yes. However, that question is about the page specifically, and the
<body>element doesn’t actually scroll; the viewport does.Try it out: make sure this page scrolls, then open a console: