On scroll function it worked with $(window) but not with $(document), why?
<p>I am working on a function where I have to hide the sticky footer once it reach an element -> <code>#line-before-related-article</code>.
When I use <code>$(document)</code> the sticky footer disappears when I start scrolling down, which is not what I want.</p>

<p>When I use <code>$(window)</code> the sticky footer disappears before of reaching <code>#line-before-related-article</code>, which is almost what I need. I want the sticky footer disappearing ONLY when it reaches the <code>div</code> with the id <code>#line-before-related-article</code></p>

<pre><code>$(window).scroll(function() {
    if ($(this).scrollTop() + $(this).height() &gt;= $('#line-before-related-article').position().top) {
        console.log(console.log($('#line-before-related-article').position().top))
        $('.sticky-footer').hide();
    }
});
</code></pre>

<p>I think my issue will be fix once my function works using <code>$(document)</code> properly.</p>

<p>Any suggestions?</p>