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

  • Home
  • SEARCH
  • 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 3425640
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:37:06+00:00 2026-05-18T06:37:06+00:00

I need some assistance with some javascript/jquery I have put in place. The function

  • 0

I need some assistance with some javascript/jquery I have put in place. The function of this client side script is to set an event handler of all images within a particular selector on a page and if the image doesnt load (eg. not found), then its removed. My client side script is as follows, triggered in the document.ready of the external javascript file.

$('.imagecontainer').error(function() { ($this).parent().hide(); });

This works, sometimes! Sometimes when the page loads it works correctly, more time it works correctly for some images but the majority of the time it doesnt work at all. What it does if the image doesnt load, the surrounding anchor tag ie. the images parent is hidden. I have included alerts in the function to check when its called and it is triggered sometime but not all the time.

So I am wondering where I am going wrong. The path/src of the image is set in server side code by C# as the path is derived on the server side and cant be changed.

Any tips or ideas on this? I read somewhere that this event should be bound prior to the source of the image is set but not sure if this is achievable as the source of the image is set in the server side.

Once I have this resolved (hopefully), I have another problem. Some of the image are dynamically loaded by a user action and are not present on the page at run time. I have got around this for 99% of events by using the jquery syntax .live(‘click’, function) etc. Does anyone know if I can do similar with the .error or how I can set it up.

  • 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-18T06:37:07+00:00Added an answer on May 18, 2026 at 6:37 am

    A couple things to note:

    Your snippet there has a syntax error. You have ($this).parent().hide(); instead of $(this).parent().hide();.

    Review the .error() documentation. Specifically, there were two things I noted. First is the observation that the call may not work properly if you are running locally. Second, in the comments, someone observed the following:

    It uses the onerror callback. This
    callback is only defined for img tags.
    Some browsers (IE,FF,…) support this
    callback on other objects too. This is
    great for a global error catching
    system (window.onerror). This
    behaviour is NOT conform to standards.
    WebKit for example does not fire this
    callback!

    Based on the small snippet you provided, it looks like you might be targeting an element that contains an image, rather than the image itself. This may very well be the source of your problem.

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

Sidebar

Related Questions

I need some help from the shell-script gurus out there. I have a .txt
I need some assistance from the Flex experts. I have an mx:Menubar , which
Hey Stack, need some assistance with the styling of jQuery UI Dialogs. You can
I need some advice as to how I easily can separate test runs for
I need some info on how to use margins and how exactly padding works.
I need some software to explore and modify some SQLite databases. Does anything similar
We need some input on what is a good design pattern on using AJAX
I need some sort of interactive chart control for my .NET-based web app. I
I need some basic CMS functionality with rich text editing. On stack overflow there
I need some information about localization. I am using .net 2.0 with C# 2.0

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.