title: JavaScript - get href attribute value via DOM traversal
body: <p>I am writing a client-side JavaScript code and I have to retrieve the URL from the <code>href</code> attribute.</p>
  
  <p>I have already travelled the DOM to a point where:</p>
  
  <pre class="lang-js prettyprint-override"><code>document.getElementById('something').getElementsByTagName('td')[3];
  </code></pre>
  
  <p>Which outputs: </p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;td&gt;&lt;a href="http://example.com"&gt;&lt;/a&gt;&lt;/td&gt;
  </code></pre>
  
  <p>From there, how do I get <code>http://example.com</code>? </p>
  
  <p>I tried using <code>.getAttribute("href")</code>, but I got <code>null</code>.</p>
  
  <p>Am I missing something?</p>