title: How to know if an h1 element is loaded?
body: <p>I have the code below to show an alert when a h1 element is loaded, but the alert is never shown, why?</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
    &lt;body&gt;
      &lt;h1&gt;Lorem ipsum&lt;/h1&gt;
      &lt;script&gt;
        var a = document.getElementsByTagName('h1');
        a[0].onload = function() { alert() };
      &lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>