title: parsing html attributes of tag javascript
body: <p>I ran into the following situation and am not able to figure out the solution, i am new to javascript, and I tried to search the internet, but couldn't find a viable solution.
  1) I want to get attributes of the tag queried for. For example if I have a tag as follows</p>
  
  <pre><code>&lt;a href = "pqr/dl/"&gt; docName &lt;/a&gt;
  </code></pre>
  
  <p>how do I get the value of href? By doing </p>
  
  <pre><code>el.getElementsByTagName("a")[0].childNodes[0].nodeValue
  </code></pre>
  
  <p>I can get only the value of the tag, i.e., "docName" by doing this.</p>
  
  <p>2) How do I query for the "img" tag?
  I have an image tag as follows</p>
  
  <pre><code>&lt;img src = "/icons/alpha.gif" alt="[DIR]"&gt;
  </code></pre>
  
  <p>if I do</p>
  
  <pre><code>console.log(el.getElementsByTagName("img")[0].childNodes[0].nodeValue)
  </code></pre>
  
  <p>it is printing "null" on the console. I need the values of src and alt.</p>
  
  <p>Thanks in advance</p>