title: How to add a class when reaching a certain element at the top of the page and delete it?
body: <p>This is my code:</p>
  
  <pre class="lang-js prettyprint-override"><code>jQuery(document).ready(function($){
      $(window).on('scroll', function(){
          if($(window).scrollTop() &gt;= $('#element').offset().top){
              $('.menu').addClass('addclass');
          }
      });
  });
  </code></pre>
  
  <p>It adds <code>addclass</code> to the menu when reaching <code>id = "element"</code> at the top of the page and scrolling further to the bottom.</p>
  
  <p>But how to remove <code>addclass</code> when <code>id = "element"</code> is again below the top of the pages.</p>