title: Access DOM on JavaScript
body: <p>I'm trying to get the textContent of a <code>a</code> tag inside an <code>ul</code> tags. The problem is that when I access the console returns me "null" instead of the element. I don't know what I am doing wrong. Hope you ca help me and thanks.</p>
  
  <p><a href="https://i.stack.imgur.com/dnDLv.png" rel="nofollow noreferrer">HTML code</a></p>
  
  <p><a href="https://i.stack.imgur.com/yYNIW.png" rel="nofollow noreferrer">JS code</a></p>
  
  <p>On other hand, the console returns me HTMLColletion but I can't get anything from there because I don't know the syntax to get the things from there, all I get is "undefined".</p>
  
  <pre><code>&lt;div class="dropdown"&gt;
           &lt;ul class="navbar-nav mr-auto "&gt;
  
              &lt;li class="nav-item"&gt;
                  &lt;a id="resumen" class="nav-link dropdown-toggle" href="#" data-toggle="dropdown"&gt; Productos 0 | Precio 0€ &lt;/a&gt;
                  &lt;ul id="productos" class="dropdown-menu"&gt;
  
  
                  &lt;/ul&gt;
  
              &lt;/li&gt;
  
           &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>The JS:</p>
  
  <pre><code>var resumen2 = document.getElementsByClassName("nav-link dropdown-toggle");
  var resumen =  document.getElementById("resumen");
  console.log(resumen);
  console.log(resumen2.textContent);
  </code></pre>