Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6229613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:35:59+00:00 2026-05-24T09:35:59+00:00

I have the following image element that it’s src does not exists. I want

  • 0

I have the following image element that it’s src does not exists. I want to use the jquery error function to detect if it has not loaded and replace the src with a generic image that I know exists. This works in chrome and firefox but on in IE. Why does this not work in IE and are there any workarounds? Thanks!

<img id="main" src="missing-image.jpg" />

<script type="text/javascript">

    $(function () {
        $("#main").error(function () {
            $("#main").attr("src", "generic.jpg");
        });
    });

</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:36:01+00:00Added an answer on May 24, 2026 at 9:36 am

    Timing issue?

    DEMO HERE

    <img id="mainImage" src="placeholder.jpg" />
    
    <script type="text/javascript">
    $(document).ready(function() {
      $("#mainImage").error(function () {
        $(this).attr("src", "generic.jpg");
      });
      $("#mainImage").attr("src","possibly_missing_image.jpg");
    });
    
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following simple preloading function which substitute an image src attribute with
I have the following script that changes my image on a timer: var da
I have a variable for the background-image attribute of an element that I need
On my web site, I have the following code: <input type=image src=images/btn.png alt=Submit border=0
I have a grid/canvas that has an element (say an icon with an image
I have an element in my document that has a background color and image
How would you trigger a click event from an element that supposedly does not
i have the following code to grow an image after you hover it: $(.myImage).hover(function
The following image have been uploaded to show what I am trying to do
I have the following simple button with an image as the template. The problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.