Answers for "REPLACE BROKEN IMAGES WITH A DEFAULT IMAGE"

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();
});
Posted by: Guest on February-03-2021

Code answers related to "REPLACE BROKEN IMAGES WITH A DEFAULT IMAGE"

Code answers related to "Javascript"

Browse Popular Code Answers by Language