title: How to fix "Uncaught TypeError: Cannot read property 'click' of null"
body: <p>I'm developing a Chrome Extension and getting the error "Uncaught TypeError: Cannot read property 'click' of null".  It works in the console and I made sure to close the console.  I'm trying to run this on the site below.</p>
  
  <p><a href="https://realtime.demo.sonicwall.com/main.html" rel="noreferrer">https://realtime.demo.sonicwall.com/main.html</a></p>
  
  <p>popup.js</p>
  
  <pre><code>document.addEventListener('DOMContentLoaded', function () {
  document.querySelector('button').addEventListener('click', int);      
  });
  function int() {
      var source = document.getElementById('j1_64_anchor').click;
  }
  var coll = document.getElementsByClassName("collapsible");
  var i;
  </code></pre>
  
  <p>popup.html </p>
  
  <pre><code>&lt;body&gt;
  &lt;button class="collapsible"&gt;Interfaces&lt;/button&gt;
  &lt;div class="content"&gt;
  &lt;button onclick="int()" class="collapsible"&gt;Interfaces&lt;/button&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>