title: jQuery - scroll to anchor on button click
body: <p>Im trying to make a simple script that checks if the user has pressed a button on the webpage. If he does so, it checks if the user has scrolled past a certain div, and if he did, the page scrolls to another else nothing happens. </p>
  
  <p>Technically, my code works since it scrolls the DOM to the anchor but as a side effect, prevents you from scrolling after it did so.</p>
  
  <pre><code>$("#scrollDownBttn").click(function(){
  
      var mainOffset = $("#pinkRegion").offset().top;
  
      $(document).on('scroll', function() {
          if ( $(document).scrollTop() &gt; mainOffset ) {
                  $(document).scrollTop( $("#brownRegion").offset().top );
  
          }
          else{
  
          }
  
      });
  });
  </code></pre>
  
  <p>Im trying to get used to jQuery, but apparently I still have a long way to go. I cant even figure out why it freezes the whole page. Any ideas why that is the case?</p>