jquery image onerror not working 1

jquery image onerror not working

function imgError(image) {
    image.onerror = "";
    image.src = "/images/noimage.gif";
    return true;
}
jquery image onerror not working 2

Here is what the above code is Doing:
1. The imgError function is called when the image cannot be loaded.
2. The image.onerror is set to an empty string. This is to prevent infinite loop.
3. The image.src is set to the path of the default image.
4. The return true is to tell the browser that the error is handled.
5. The onerror event handler is added to the image tag.

Similar Posts