title: How to get href value using jQuery?
body: <p>I'm trying to get href value using jQuery:</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Jquery Test&lt;/title&gt;
           &lt;script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript"&gt;
          $(document).ready(function() {
              $("a").click(function(event) {
                  alert("As you can see, the link no longer took you to jquery.com");
                  var href = $('a').attr('href');
                  alert(href);
                  event.preventDefault();
              });
          });
          &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;a href="http://jquery.com/"&gt;jQuery&lt;/a&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>But it doesn't work. Why?</p>