Check if image link is broken in page and replace it with the alt text and open the blank page when user click on it
$('img').each(function( ) {
$( this ).error(function(){
var img_path = $(this).attr('src');
var img_alt = $(this).attr('alt');
$(this).after('<a href='+img_path+' target=_blank>'+img_alt+'</a>');
$(this).hide();
});
In above code-
$('img').each(function( ) { : This function will search all image link on the page
$( this ).error(function(){ : this will check whether image exists or not.
var img_alt = $(this).attr('alt'); : it will get the alt attribute of the image link.
$(this).after(''+img_alt+''); this will replace the entire image with the alt text or alt attribute.
0 Comment(s)