What's the scroll from the bottom?
elem.scrollTop property is the size of the scrolled out part from the top. How to get the size from the bottom scroll (let’s call it
Write the code that works for an arbitrary
P.S. Please check your code: if there’s no scroll or the element is fully scrolled down, then it should return
The solution is:
let scrollBottom = elem.scrollHeight - elem.scrollTop - elem.clientHeight;
In other words: (full height) minus (scrolled out top part) minus (visible part) – that’s exactly the scrolled out bottom part.