title: Error Scrolltop: top not defined
body: <p>I get the following error </p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot read property 'top' of undefined.</p>
  </blockquote>
  
  <p>It's talking about the <code>top</code> that is standing in the line: <code>$(html, body).. , 1000, function</code> but I really have no clue how to fix this error. I have tried multiple other posts with a fairly similar problem, but none of them fixed my problem so far.</p>
  
  <pre><code>// Menu Scroll to content and Active menu
  var lastId,
    topMenu = $("#menu"),
    topMenuHeight = topMenu.outerHeight() + 145,
    menuItems = topMenu.find("a"),
    scrollItems = menuItems.map(function() {
      var item = $($(this).attr("href"));
      if (item.length) {
        return item;
      }
    });
  
  $('a[href*=#]').bind('click', function(e) {
    e.preventDefault();
  
    var target = $(this).attr("href");
  
    $('html, body').stop().animate({
      scrollTop: $(target).offset().top - 60
    }, 1000, function() {});
  
    return false;
  });
  
  $(window).scroll(function() {
    var fromTop = $(this).scrollTop() + topMenuHeight;
    var cur = scrollItems.map(function() {
      if ($(this).offset().top &lt; fromTop)
        return this;
    });
  
    cur = cur[cur.length - 1];
    var id = cur &amp;&amp; cur.length ? cur[0].id : "";
  
    if (lastId !== id) {
      lastId = id;
      menuItems
        .parent().removeClass("active")
        .end().filter("[href=#" + id + "]").parent().addClass("active");
    }
  });
  </code></pre>