title: Why doesn't JS call a function on scroll?
body: <pre><code>function mobileNavTop () {
    if($('#mobile-navigation').offset().top &lt;= 25) {
      $('#mobile-navigation').css({'position':'absolute', 'right':'0', 'top':'18px'});
      $('.jq1').css({'position':'absolute'});
      $('.move_up').hide();
    } else {
      $('#mobile-navigation').removeAttr('style');
      $('.jq1').removeAttr('style');
      $('.move_up').removeAttr('style');
    }
  }
  $(document).ready(function(){
    move_up = $('.move_up');
  
    $('.move_up').click(function(){
      $('html, body').animate({ scrollTop: 0 }, 'slow');
    });
  
    if ($('#mobile-navigation').offset().top &lt;= 25) { move_up.hide(); }
  
    mobileNavTop();
  });
  
  $(window).scroll(function(){
    mobileNavTop();
  });
  </code></pre>
  
  <p>The idea is that when I have the navigation scrolled lower than 25px from the top, a bit of <code>css</code> happens. And this works on <code>document.ready</code>, but not on <code>scroll</code> (it doesn't <code>removeAttr('style')</code> for whatever the reason. What could cause this?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>It works if I scroll up (load the page when <code>offset().top &gt; 25</code>), but not if I scroll it down.</p>