title: Jquery scroll to offset target div on page load
body: <p>I'm trying to scroll to the div that is in the URL. It could be one of 21 IDs like:</p>
  
  <p>url.com/test#lite1</p>
  
  <p>url.com/test#lite2</p>
  
  <p>url.com/test#lite3</p>
  
  <p>I need this to happen on page load (user is coming from an ebook and should see the exact item they clicked on).</p>
  
  <p>Here is the code I currently have:</p>
  
  <pre><code>$(document).ready(function(){
      $('a[href^="#"]').load(function() {
          e.preventDefault();
  
          var target = this.hash;
          var $target = $(target);
  
          $('html, body').stop().animate({
              'scrollTop': $target.offset().top -150
          }, 900, 'swing', function () {
              window.location.hash = target;
          });
      });
  });
  
  &lt;/script&gt;
  </code></pre>
  
  <p>It doesn't work and I think it's because of this part (I have no idea what I'm doing here):</p>
  
  <pre><code>$('a[href^="#"]').load(function() {
  </code></pre>
  
  <p>I also want it to be in the center of the page (not at the top cut off like browsers do when scrolling to divs). Please let me know if this is correct:</p>
  
  <pre><code>$target.offset().top -150
  </code></pre>
  
  <p>Thanks so much in advance!</p>