Reputation: 1
$image ='< img src="http://xyz.com/'.$add_image4.'" class="magnify" alt="/>';
& if $add_image4
is empty,blank image still shows how do I remove it?
Upvotes: 0
Views: 206
Reputation: 18078
Here's how to do it in jQuery :
$(function() {
$("img.magnify").on('error', function() {
$(this).remove();
});
});
As written, all img nodes with class="magnify"
will be removed if they fail to load.
The "img.magnify" selector can be adjusted to address more/less/different img nodes as required.
Upvotes: 0