title: Alerting return value shows correct string whereas storing as variable returns undefined
body: <p>This returns the expected value:</p>
  
  <pre><code>alert($('#previous a').attr("href"));
  </code></pre>
  
  <p>This returns <code>undefined</code>:</p>
  
  <pre><code>var a = $('#previous a').attr("href");
  alert(a)
  </code></pre>
  
  <p>I could not figure out why. Can someone help me :)</p>