在div上查找scrollTop的最大底值?

我需要一种方法来自动找到scrollTop的最大底值,div id为“#box”。

这样的事情: 如何获得最大的文档滚动值

但只是在div中,而不是整个浏览器窗口。 我怎样才能做到这一点?

干得好:

var trueDivHeight = $('.someclass')[0].scrollHeight; var divHeight = $('.someclass').height(); var scrollLeft = trueDivHeight - divHeight; alert(scrollLeft); 

这是一个考虑填充并使用prop而不是直接访问DOM元素的版本。

 $('#box').prop('scrollHeight') - $('#box').innerHeight(); 

看这里一个完整的答案:

https://stackoverflow.com/a/48246003/7668448

如何在jquery中使用它:

 var max = $('#element')[0].scrollLeftMax; // when using the polyfill var max = $('#element')[0].scrollLeftMaxi(); // when using the other alternative more support IE6+