title: Javascript: How to add an event listener to the body of a CMS, with the JS code in the header
body: <p>I wrote a script that adds a listener to a  for an onClick event.  When clicked, it searches the document for any element with a specific class "someclass", and then performs some operations on it etc..</p>
  
  <p>The problem is, after finding all the elements with class="someclass", the array of all the elements with class="someclass" is null.  I think this is because the JS code that adds the listener is in the header, and when it runs, the body (that comes from a different php file from the CMS) that contains the actual  has no yet loaded.</p>
  
  <p>What do I do about this?</p>
  
  <p>A side note, I am trying to do this using pure JS.  I do not want to have anything other than one single external .js file.  So that means no jquery or other API's, and no editing the html.</p>
  
  <p>What are my options here?  Thank you for reading.</p>