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 1019759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:03:49+00:00 2026-05-16T11:03:49+00:00

I have a table which repeats an image link to a file download for

  • 0

I have a table which repeats an image link to a file download for every row of data. I want to use Jquery or Javascript to detect if a image link returns a 404 error, meaning the file its trying to find doesn’t exist, then set the image link to display:none so its hidden.

Any help is much appreciated!

Jamie.

—Edit—

This is my url which needs to be set to hidden if it cant find the .igs file

<a href="/path/to/file.igs"><img src="pic.jpg" alt="My Image Link"></a>

Unfortunately I cannot utilize server-side processing.

  • 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-16T11:03:49+00:00Added an answer on May 16, 2026 at 11:03 am

    You can use the error() event handler:

    $("img").error(function () {
        $(this).css("display", "none");
    });
    

    I see that a few of us misunderstood your origin question, your edit clears it up a little. You can achieve what you want only by using AJAX. Just requesting the headers for the file should be enough:

    // Find all <a> tags where href ends with .igs, hide and loop over them 
    $("a[href$=.igs]").hide().each(function (i, el) {
        $.ajax({
            type: "HEAD",
            url: el.href,
            success: function () {
                // Success, we can unhide the element.
                el.show();
            }
        });        
    });
    

    Of course, this won’t work if the files are on other domains. Also, this can be quite a costly procedure for both the client and the server if there’s a lot of them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following jQuery script which hides/expands row in table: it was inspired
I have a table which needs to link one of three seperate tables, but
I have a table which has two text boxes and an image beside it
I have this php function, which I want to convert to javascript function, but
I have a table which uses a background image that is 1500px wide. Since
i have one section table which contain the section and i want to delete
I have a table cell in which i have to set a background image,
I have a table which has a background image(sprite). The td of the table
I have table which contains double values stored in mysql database ...I need to
I have a table which has codes and is linked with a table of

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.