broken image code example

Example 1: REPLACE BROKEN IMAGES WITH A DEFAULT IMAGE

$('img').on('error', function (){
	$(this).attr('src', '/path/to/image/default.png');
});

/*// OR hide
---------------------------*/
$('img').on('error', function(){
	$(this).hide();
});

Example 2: broken hyperlink

1-Collect all the links in the web page based on <a> tag.
2-Send HTTP request for the link
and read HTTP response code.
3-Find out whether the link is valid 
or broken based on HTTP response code.
4-Repeat this for all the links captured.