title: How can i solve Uncaught TypeError: Cannot read property 'top' of undefined
body: <p>i have one page website.
  i added smoothscroll with js.</p>
  
  <pre><code>$(document).ready(function(){
      $("li &gt; a").on('click', function(e) {
      if (this.hash !== "") {
        e.preventDefault();
        var hash = this.hash;
  
      $('html, body').animate({
           scrollTop: $(hash).offset().top
         }, 800, function(){
       window.location.hash = hash;
       });
      }
     });
    });
  </code></pre>
  
  <p>and here's my navigation html code:</p>
  
  <pre><code>&lt;li class="{{ slug == '/' ? 'active' : '' }}"&gt;&lt;a href="#home"&gt;HOME&lt;/a&gt;&lt;/li&gt;
  &lt;li class="{{ slug == '/about' ? 'active' : '' }}"&gt;&lt;a href="#about"&gt;ABOUT&lt;/a&gt;&lt;/li&gt;
  &lt;li class="{{ slug == '/blog' ? 'active' : '' }}"&gt;&lt;a href="#blog"&gt;BLOG&lt;/a&gt;&lt;/li&gt;
  </code></pre>
  
  <p>but when i go to another page (like blog), i got error top when click the navigation to go to onepage again.
  did i missed something?</p>