title: check if page at a certain section
body: <p>I want to trigger a function when the user is on a section of the page with a specific ID (either through a link or scroll). This is what I have now but it's not working.</p>
  
  <pre><code>$(document).ready(function() {
      if (window.location.pathname == '/index.html#contact') {
          console.log('Viewing contact form');
      }
  });
  </code></pre>
  
  <p>UPDATE: Found what I was looking for. This is what I used:</p>
  
  <pre><code>$(window).bind('scroll', function() {
      if($(window).scrollTop() &gt;= $('#contact').offset().top - 50) {
          $('.modal').modal('hide');
      }
  });
  </code></pre>
  
  <p>The "- 50" is to account for my margins and paddings. When using the subtract symbol it 'assumes' your section starts higher on your page. For lower, use addition.<br>
  The "$('.modal').modal('hide');" is not needed. This is to hide a bootstrap modal when the user is on the #contact section of the page.</p>