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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:51:09+00:00 2026-06-14T17:51:09+00:00

I add images dynamically, simply but appending an img tag, with a dynamic source,

  • 0

I add images dynamically, simply but appending an img tag, with a dynamic source, to an existing div.
But, not all of these images will exist, and I would like to hide the ones, that doesn’t.

I believe I can use load() and setup a hide function on error, but since I add them, simply by creating an img tag, I don’t really know how to hook up my jquery to it.

Here is my add function:

function GetImages() {
            $('#ImageContainer').empty();
            $('#ImageContainer').css("visibility", "visible");

            var regex = new RegExp("(.+?);", "g");
            var match;
            while (match = regex.exec($("#<%= HttpSources.ClientID %>").val())) {
                $('#ImageContainer').append('<div class="ImgBox"><img src="' +
                    match[1].format($("#<%= ItemNo.ClientID %>").val()) + '" class="Image" /></div>');
            }

            return false;
        }

It adds a div with an img, into another div.

Originally, I wanted to do something like this, to hide them, but since the divs and images doesn’t exist when the document is loaded, I don’t really see how I can hook it up to them.

$(document).ready(function() {
    $(".ImgBox").Next(".Image").load(function () {
        // ... loaded  
    }).error(function () {
        // ... not loaded
        $(this).hide();
    });
});
  • 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-06-14T17:51:10+00:00Added an answer on June 14, 2026 at 5:51 pm

    I hate to answer my own question, but here’s what I ended up with.

    .live() sounded great, but unforunately, it doesn’t work with load/error on the img.

    Instead, I found this:
    http://www.sajithmr.me/javascript-check-an-image-is-loaded-or-not
    which seems to give me a way to check, if an image is loaded. After adding all the images, I will run them through, and clean up the not loaded.

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

Sidebar

Related Questions

I am using iCarousel as shownh here .But I want to add images dynamically
I insert dynamically some images used as buttons and add an onClick event. $(img.image_edit_customer).live(click,
I am loading images externally using jQuery load function.. but not able add light
I have searched many places to add and display images dynamically on JPanel but
I'm trying to add images dynamically in a div element. So I have a
Is there a way to add images dynamically to a photoswipe gallery after it
While we can add Inline Images in paragraphs there does not appear to be
I'm trying to set the src of an img tag I have dynamically. The
I need to add images into res/drawable folder dynamically as the user select images
I'm using a function to add images to a site. These go into a

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.