jquery select dynamically added images on error
<p>Iam using js/jQuery to add images to my site like this:</p>

<pre><code>var img = document.createElement("img");
img.width = imgWidth;
img.file = fileList[i];
img.name = 'pic_' + i;
img.classList.add("obj");
</code></pre>

<p>But sometimes the url is broken because the image does not exist.
In this case I would like to hide the broken image.
The Problem is that Iam not able to catch the onerror event... if there is any.
All I see is the broken image with this code:</p>

<pre><code>&lt;img width="200" src="php/upload.php?action=showPic&amp;amp;newsId=239"&gt;
</code></pre>

<p>I tried a couple of things:</p>

<pre><code>$("img").error(function () {
    alert("error");
});
</code></pre>

<p>or with live:</p>

<pre><code>$("img").live('load',(function() { console.log("image loaded correctly"); }));
$("img").live('error',(function() { console.log("image error"); }));
</code></pre>

<p>But no events are getting triggered :-/</p>

<p>Any ideas?
Thanks!</p>
