title: How to smooth scroll using location.hash?
body: <p>I'm trying to put a smooth scroll in location.hash, but it seems it's not working.</p>
  
  <p>How to fix this?</p>
  
  <p>JS</p>
  
  <pre><code>function test_function(){
      window.location.hash = '#divid';
      jQuery(document).ready(function($){
          $('html, body').animate({ scrollTop: $(test_function).target.offset().top }, 1000);
      });
  }
  </code></pre>
  
  <p>HTML</p>
  
  <pre><code>&lt;div&gt;
  &lt;a href="&lt;?php echo $_POST['referrer'] ?&gt;#divid"&gt;Find a store&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>