title: How to access same element in multiple javascript files
body: <p>I tried this:</p>
  
  <p>in <code>constant.js</code></p>
  
  <pre><code>const CONFIRM_BUTTON = document.querySelector(".confirm-button");
  export { CONFIRM_BUTTON };
  </code></pre>
  
  <p>in some-file.js,</p>
  
  <pre><code>import { CONFIRM_BUTTON } from './constants';
  CONFIRM_BUTTON.onclick = someFunction;
  </code></pre>
  
  <p>I am getting <code>Cannot set property 'onclick' of null</code> error in doing so.</p>
  
  <p>If in some-file.js file, I do following, it works:</p>
  
  <pre><code>const CONFIRM_BUTTON = document.querySelector(".confirm-button");
  CONFIRM_BUTTON.onclick = someFunction;
  </code></pre>
  
  <p>I am trying to do this <code>const CONFIRM_BUTTON = document.querySelector(".confirm-button");</code>  once and use it multiple js files? How can I do that?</p>