Computer Magic Logo
Fix broken images

Friday, January 22, 2016

Published by Aristotelis Pitaridis

Sometimes one ore more images have broken links so the image does not appear on the screen. In that case we can use the following code so that we will replace them with a different image.

$('img').error(function() {
    $(this).attr('src', '/images/broken.png');
});