Do you know how to hide the classic “Image not found” or broken icon, but the alt still exist from a rendered HTML page when an image file is not found?
Like this,
<img id="testImg" src="#" alt="No Image"/>
:
change to: No Image (show the alt only)
Any working method using JavaScript/jQuery/CSS? Thank's
You can try this
alt
textimg
img
, or hide it if you wantfunction doSomething(elem){
var alt = document.createTextNode( elem.getAttribute('alt') );
elem.parentNode.insertBefore( alt, elem );
elem.parentNode.removeChild( elem );
}
<img src="actual_image_src" alt="helloworld" onerror="doSomething(this)" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With