title: Uncaught TypeError: Cannot read property 'substr' of undefined - old Jquery
body: <p>I'm updating an old project that used jquery-1.4.3.min.js. This was interfering with some new  stuff I was working on so I had to replace it with the up to date verson, and now I get Uncaught TypeError: Cannot read property 'substr' of undefined.</p>
  
  <p>Been working on this one for a while and I'm stumped. Any help is greatly appreciated!</p>
  
  <p>The line it's from</p>
  
  <pre><code>$link = $('a[hash=#' + $inview + ']').parent().attr('id').substr(4);
  </code></pre>
  
  <p>Here's the whole bit if needed</p>
  
  <pre><code> $(window).scroll(function() {
      $inview = $('section:in-viewport header').parent().attr('id');
      if ($('a[hash=#' + $inview + ']') !== null) {
          $link = $('a[hash=#' + $inview + ']').parent().attr('id').substr(4);
      }
  
      if ($link != $nCurrentActive &amp;&amp; scrolling == 1) {
          $nav.removeClass('active');
          offMenu($nCurrentActive);
          $nCurrentActive = $link;
          $('#nav-'+$nCurrentActive).addClass('active');
          onScrollMenu($nCurrentActive);
      }
  });
  </code></pre>