 <p>I'm assuming your question was confusingly written so I've edited it with what I believe you meant. Here is what I would suggest:</p> <pre><code>$(document).ready(function(){ var $container = $("#containerImage img"); $container.click(function(){ if (!$(this).attr("src")) { $(this).remove(); } else { console.log("not empty"); } }); $container.click(); }); </code></pre> <p><a href="http://jsfiddle.net/ZmKvq/" rel="nofollow">http://jsfiddle.net/ZmKvq/</a></p> <p>Fade out demo to show it working:</p> <p><a href="http://jsfiddle.net/ZmKvq/1/" rel="nofollow">http://jsfiddle.net/ZmKvq/1/</a></p> <p>In other words, just call the event handlers.</p> <p>Here is another approach, in case you're allergic to calling the click handler en masse:</p> <pre><code>$container .filter(function(){return !this.getAttribute('src')}) .fadeOut( 1000, function(){$(this).remove();} ); </code></pre> <p><a href="http://jsfiddle.net/ZmKvq/3/" rel="nofollow">http://jsfiddle.net/ZmKvq/3/</a></p>