title: Add a class to a DIV when top of the window reach a specific element and remove it when not
body: <p>I have a <code>.navigation</code> in the top of the wrapper.
  I want to add it a <code>.fixed</code> class, when the top of the window reached the <code>.bottom</code> DIV &amp; remove this class when the top of the <code>.bottom</code> is in the window`s scope (it's a toggling between add and remove .fixed class). </p>
  
  <p><img src="https://i.stack.imgur.com/rlJka.gif" alt="add fixed class to the navigation"></p>
  
  <pre><code>&lt;div id="wrapper"&gt;
      &lt;div class="navigation"&gt;
          &lt;!-- There are some list elements here --&gt;
      &lt;/div&gt;
      &lt;div class="bottom"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>It's what I made, but not work</p>
  
  <pre><code>bottom     = $('.bottom');
  $(window).scroll(function(){    
      if ($(this).scrollTop() &gt; bottom){ 
          $('.navigation').addClass('fixed'); 
      }
      else{
          $('.navigation').removeClass('fixed');
      }
  });
  </code></pre>