Aparna
Aparna

Reputation: 11

<img src="image_not_found.jpg" onError="this.style.display = 'none';" alt="" /> -not working in chrome

<img src="image_not_found.jpg" onError="this.style.display = 'none';" alt="" />

The above code does not work in chrome, after deleting still shows image not found. But it works in firefox, what else should i add to make it work in chrome. Mine is a php website

Upvotes: 1

Views: 12283

Answers (2)

Wayne Gakuo
Wayne Gakuo

Reputation: 1

This might be of help if you want to style 'onerror' or broken images. It really resolved an issue I battled with for a while.

<img src="/path/toimage" alt="my image" onerror="this.onerror=null;this.src='/broken-img.svg';this.classList.add('broken-img');">

Upvotes: -1

freethinker
freethinker

Reputation: 2435

Try small letters:

onerror="this.style.display = 'none'"

Upvotes: 4

Related Questions