title: addEventListener not working as it should
body: <p>I have problem with adding event listener into JS...If i connect button with onclick attribute its working but if I delete it in HTML and try to add eventListener('click', myFunction), its not working. And btw its a simple dropdown button.</p>
  <p>In following example in button i deleted onclick=&quot;myFunction&quot; and added this - &gt;</p>
  <p>JavaScript:</p>
  <pre><code>document.getElementById(&quot;btn&quot;).addEventListener('click', myFunction);
  
  function myFunction() {
      document.getElementById(&quot;myDropdown&quot;).classList.toggle(&quot;show&quot;);
  }
  
  window.onclick = function(event) {
    if (!event.target.matches('.dropbtn')) {
      var dropdowns = document.getElementsByClassName(&quot;dropdown-content&quot;);
      var i;
      for (i = 0; i &lt; dropdowns.length; i++) {
        var openDropdown = dropdowns[i];
        if (openDropdown.classList.contains('show')) {
          openDropdown.classList.remove('show');
        }
      }
    }
  }
   
  </code></pre>
  <p>HTML:</p>
  <pre><code>&lt;button id=&quot;btn&quot; class=&quot;dropbtn&quot;&gt;RECEPT&lt;/button&gt;
  &lt;div id=&quot;myDropdown&quot; class=&quot;dropdown-content&quot;&gt;
    &lt;ul&gt;
      &lt;li&gt;-5 jaja&lt;/li&gt;
      &lt;li&gt;-0.2l mleka&lt;/li&gt;
      &lt;li&gt;-100g slanine&lt;/li&gt;
      &lt;li&gt;-200g brasna&lt;/li&gt;
      &lt;li&gt;-10g putera&lt;/li&gt;
      &lt;li&gt;-50g sira&lt;/li&gt;
      &lt;p class=&quot;recipeInfo&quot;&gt;Kuvati na laganoj vatri i ostaviti da se krcka 5 minuta&lt;/p&gt;
    &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  <p>I dont know what is the problem nor solution...Any help?</p>