JQuery scroller error
<p>I'm using this example of a page scroller which also sets the navigation as active on scroll.</p>

<p><a href="http://jsfiddle.net/m2zQE/" rel="nofollow">Example</a></p>

<p>Hope you can help.</p>

<p>In the console I see this error.</p>

<blockquote>
  <p>TypeError: $(...).offset(...) is undefined [Break On This Error]  </p>
  
  <p>contentTop.push( $( $(this).attr('href') ).offset().top );</p>
</blockquote>

<p>HTML</p>

<pre><code>&lt;nav id="nav"&gt;
    &lt;ul&gt;
        &lt;li&gt;&lt;a href="#1"&gt;B&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="#2"&gt;B&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="#3"&gt;C&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="#4"&gt;D&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="#5"&gt;E&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="#6"&gt;F&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
&lt;/nav&gt;
</code></pre>

<p>JS</p>

<pre><code>smoothScroll: function() {
     var topRange      = 200,  // measure from the top of the viewport to X pixels down
         edgeMargin    = 20,   // margin above the top or margin from the end of the page
         animationTime = 1200, // time in milliseconds
         contentTop = [];

     // Stop animated scroll if the user does something
     $('html,body').bind('scroll mousedown DOMMouseScroll mousewheel keyup', function(e){
     if ( e.which &gt; 0 || e.type == 'mousedown' || e.type == 'mousewheel' ){
      $('html,body').stop();
     }
    })

     // Set up content an array of locations
     $('#nav').find('a').each(function(){
      contentTop.push( $( $(this).attr('href') ).offset().top );
     })

     // Animate menu scroll to content
      $('#nav').find('a').click(function(){
       var sel = this,
           newTop = Math.min( contentTop[ $('#nav a').index( $(this) ) ], $(document).height() - $(window).height() ); // get content top or top position if at the document bottom
       $('html,body').stop().animate({ 'scrollTop' : newTop }, animationTime, function(){
        window.location.hash = $(sel).attr('href');
       });
       return false;
     })

     // adjust side menu
     $(window).scroll(function(){
      var winTop = $(window).scrollTop(),
          bodyHt = $(document).height(),
          vpHt = $(window).height() + edgeMargin;  // viewport height + margin
      $.each( contentTop, function(i,loc){
       if ( ( loc &gt; winTop - edgeMargin &amp;&amp; ( loc &lt; winTop + topRange || ( winTop + vpHt ) &gt;= bodyHt ) ) ){
        $('#nav li a')
         .removeClass('selected')
         .eq(i).addClass('selected');
       }
      })
     })
  },
</code></pre>
