有这样的元素:
<div id="threads-list" style="overflow-y: scroll; height: 200px;">
// Posts
</div>
当用户到达按钮(或距离按钮 10px)时,我如何提醒()?
这就是我现在正在尝试的:
$('#threads-list').scroll(function() {
if ($('#threads-list').height() + $('#threads-list').scrollTop() == document.getElementById('threads-list').offsetHeight) {
console.log('do');
}
});
似乎问题在于 .offsetHeight 返回与 .height() (均为 200px)相同,后者是容器高度但不是里面的内容,我认为获得内容的正确高度将是解决问题的关键。