title: jquery scrolltop from Hash url
body: <p>i want to the page to smooth scroll to an anchor based on the hash URL when the page loads.</p>
  
  <p>ie</p>
  
  <p>www.domain.com/pagename/#matches</p>
  
  <p>I have this, but it's not working</p>
  
  <pre><code>var elem = $('#_' + window.location.hash.replace('#', ''));
  if(elem) {
       $('html,body').animate({
            scrollTop: $('#' + elem).offset().top-65
          }, 1000);
          return false;
  }
  </code></pre>
  
  <p>Console error is</p>
  
  <p>Syntax error, unrecognized expression: #[object Object]</p>
  
  <p><strong>Update</strong></p>
  
  <p>I got it working with</p>
  
  <pre><code>if(window.location.hash) {
       var elem = window.location.hash;
       $('html,body').animate({
            scrollTop: $(elem).offset().top-65
          }, 1000);
          return false;
  }
  </code></pre>
  
  <p>However when the animation finishes, the default anchor action kicks in and thus jumps the page and ignores the offset im trying to achieve </p>