Is there a way to check if an image exists using jQuery?
I thought the following would work but it doesn’t and console.log shows Error 404 for the image if it doesn’t exist.
$("#icon").html("<img src='/assets/img/"+condition+".png'>");
if (!$("#icon")){
$("#icon").html("nothing to show");
}
try this :