title: Remove background image on image load
body: <p>I'm loading image tags via AJAX and inserting them with the conventional <code>.html(content)</code> function in jQuery alongside a bunch of other HTML. However, this question still applies if you're loading a page from scratch. Now, I have a background image placeholder to be put there while the image loads. I want this background image to go away when the image loads.</p>
  
  <p>Problem:</p>
  
  <p>If I attach a conventional <code>.load(function)</code> event listener, I am concerned that the image might load before the hook is applied (putting the hook in a small JS <code>&lt;script&gt;</code> right after the image instead of in a <code>$(function(){})</code> block might help a bit). I have yet to encounter such behaviour, but I know of nothing in the specification that prevents this from happening (since the image tag ought to be fully parsed before the hook is applied).</p>
  
  <p>My current solution. Put the command in an inline <code>onload=</code> property within the image tag.</p>
  
  <p>Is there a better way?</p>