Reload matched image
<p>I'm testing if an img's src attribute matches a certain string. When it does I expect it to change the src attribute and make the image reload.</p>

<p>So far I've tried this but it is not working:</p>

<pre><code>$('img').error(function(){
    if($(this).attr('src') == 'some_img_url.jpg'){
        $(this).attr('src', 'site_media/banner.jpg?_=' + Math.random());
    }
});
</code></pre>

<p>Any idea why this is not working?</p>

<p>edit:</p>

<p>It was a url problem just like NAVEED said, it works now,  I'm using jquery 1.5.1</p>
