 <p><kbd><strong><a href="http://jsbin.com/itepap/3/edit" rel="nofollow">LIVE DEMO</a></strong></kbd></p> <p><code>$(this).addClass('myClass');</code> would work but use:</p> <pre><code>var img = $("&lt;img /&gt;", { "src" : '/images/favicon.png', "class" : 'myClass' }) .error(function(){ console.log('error'); }) .load(function(){ img.appendTo( theParent ); }); </code></pre>