A lot of times non existing images come up on webpages that you are unaware of. Here is an easy way to handle non existing images.
We can use error
event on img tag to verify whether images exist or
not.
<img src="pic-1,jpg" alt="" id="example" /> <script type="text/javascript"> $(document).ready(function () { $("#example").bind("error", function () { if (confirm("Unable to load image, would you like to load different image?")) { $("#example").attr("src", 'pic-1.jpg'); } }); }); </script>