title: How to change html content, when the page has fully loaded
body: <p>So, I have this HTML document</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
    &lt;title&gt;TestPage&lt;/title&gt;
      &lt;script src="script.js"&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;p id="test"&gt;Sample text&lt;/p&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>With this JS file</p>
  
  <pre><code>window.addEventListener("load", MyFunction());
  function MyFunction(){
    document.getElementById("test").innerHTML = "it worked";
  }
  </code></pre>
  
  <p>and ofcourse this doesn't work (the text isn't changed), since it loads the script before it actually loads the <code>&lt;p id="test"&gt;&lt;/p&gt;</code> element (I think). It may seem strange, but I want to change the content of some elements, after everything has loaded. I have searched, but to no avail. I'm missing something obvious here probably, but I can't seem to figure it out. Any advice would be appreciated!</p>