title: onclick not working in external js-file, but in inline
body: <p><strong>What I want</strong> : change text-color to red on text in a <code>&lt;h1&gt;</code>tag with <code>&lt;id="headline"&gt;</code></p>
  
  <p>Anyone that has an idea why the following code does not work, but further down in this question, that code work by moving onclick-event to inline code?</p>
  
  <p><strong>Does not work</strong> : following code written in external js-file</p>
  
  <pre><code>function changeColor(){
      document.getElementById("headline").style.color = "red";
  }
  
  document.getElementById("headline").onclick = changeColor;
  </code></pre>
  
  <hr>
  
  <p><strong>Works</strong> : Following code written in external js-file (function is the same):</p>
  
  <pre><code>function changeColor(){
      document.getElementById("headline").style.color = "red";
  }
  </code></pre>
  
  <p>…and this written in inline code:</p>
  
  <pre><code>&lt;h1 id="headline"  onclick="changeColor()"&gt;with inline code this text change color on click&lt;/h1&gt;
  </code></pre>