title: How can an external Javascript file affect an HTML file's DOM?
body: <p>Say we have this code for our HTML file:</p>
  
  <pre><code>&lt;html&gt;
   &lt;head&gt;
    &lt;script src="totti.js"&gt;&lt;/script&gt;
   &lt;/head&gt;
   &lt;body&gt;
    &lt;span id="tim"&gt;this'll change on load&lt;/span&gt;
   &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And since I don't know how exactly I can do this, this is the code I want to implement (eg. totti.js):</p>
  
  <pre><code>function changeText(){
   document.getElementById("tim").innerHTML = "changed text";
  }
  changeText();
  </code></pre>
  
  <p>I suppose we need to define its id into a variable first, or pass in it as an arguement in the HTML side? Help would be appreciated. Thanks.</p>