Do you know how to hide the classic “Image not found” icon from a rendered HTML page when an image file is not found?
Any working method using JavaScript/jQuery/CSS?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use the
onerrorevent in JavaScript to act when an image fails to load:In jQuery (since you asked):
Or for all images:
You should use
visibility: hiddeninstead of.hide()if hiding the images might change the layout. Many sites on the web use a default “no image” image instead, pointing thesrcattribute to that image when the specified image location is unavailable.