title: Check if an image is loaded (no errors) with jQuery
body: <p>I'm using JavaScript with the jQuery library to manipulate image thumbnails contained in a unordered list. When the image is loaded it does one thing, when an error occurs it does something else. I'm using jQuery <code>load()</code> and <code>error()</code> methods as events. <strong>After these events I check the image DOM element for the .complete to make sure the image wasn't already loaded before jQuery could register the events.</strong></p>
  
  <p><strong>It works correctly except when an error occurs before jQuery can register the events.</strong> The only solution I can think of is to use the img <code>onerror</code> attribute to store a "flag" somewhere globally (or on the node it's self) that says it failed so jQuery can check that "store/node" when checking .complete.</p>
  
  <p>Anyone have a better solution?</p>
  
  <p><strong>Edit: Bolded main points and added extra detail below:</strong>
  I'm checking if an image is complete (aka loaded) AFTER I add a load and error event on the image. That way, <strong>if the image was loaded before the events were registered, I will still know.</strong> If the image isn't loaded after the events then the events will take care of it when it does. The problem with this is, I can easily check if an image is loaded already, but <em>I can't tell if an error occurred instead.</em></p>