Replace broken image with noimage icon using Jquery
- by hmloo
Sometimes when the image isn't available on server, the web page will show a broken image. so we can display a "no image available" image for good user experience. I will implement it using Jquery. $(document).ready(function()
{
$("img").error(function()
{
$(this).hide();
})
.attr("src", "noimage.jpg");
});
Please note that we must first hide the broken image, or else even if we set the src to noimage, it still can not show noimage icon.