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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:31:39+00:00 2026-05-28T00:31:39+00:00

So apparently I’m trying to do something that jQuery does not like. I’m using

  • 0

So apparently I’m trying to do something that jQuery does not like.

I’m using javascript to upload pictures. Every time a picture is uploaded I want it to be visible as well as have a working remove script attached to it. The display works fine, the remove does not because it does not exist on the page when I inspect it with firebug.

This is the script for removing the file:

var insertScript = "<";
insertScript += "script type='text/javascript'>jQuery(document).ready(function($){ $('#Remove_" +
    file + "').click(function() { removeImage(\"" +
    fileName +"\", \""+ imageUID +"\", \"" +
    file + "\"); }); });";
    insertScript += "<";
    insertScript += "\/script>";

In my page I have a div tag that holds all the images, so I am appending to it every time an image is uploaded as such:

jQuery(document).ready(function($) {
    $('#ImageBar').append(insertScript);
    $('#ImageBar').append(insertHTML);
});

The insertHTML variable holds a div tag with the image inside of it and a remove button. No javascript/jquery in it. It appends fine. The insertScript does not append at all.

I tried on a hunch to remove the jQuery from the insertScript and replace it with a simple javascript alert and test if it was the tags that mess it up, and it’s not. The alert worked fine when appended. Which leads me to believe that jQuery does not like appending jQuery. Is there another way of going about doing this?

  • 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-28T00:31:40+00:00Added an answer on May 28, 2026 at 12:31 am

    I would suggest that you use data attributes on your image tags for the image to store the data needed for the removal. You can then give the closer button a class and use a document-level handler that filters elements with that class for the handler. Use the relative positioning of the button to get access to the image.

    <span class="image-container">
    <img  data-filename="foo.png" data-imageuid="35" data-file="foo" ... />
    <button class="remove-image">X</button>
    </span>
    

    With a script on your page as:

    <script type="text/javascript">
        $(function() {
             $(document).on('click','.remove-image', function() {
                 var $button = $(this),
                     $img = $button.prev('img'),
                     $container = $button.closest('.image-container');
                     removeImage( $img.data('filename'), $img.data('imageuid'), $img.data('file') );
                     $container.remove();
             });
        });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Apparently I can't move files on different volumes using Directory.Move. I have read that
Apparently some vendors (like Telerik) are working on versions of their controls that do
Apparently I've done something I'm not aware of All my classes now have warnings
Apparently Python only supports 2 minor versions (like 2.X), so that would mean Python
Apparently, the PictureBox class does not offer an event when its Image property is
Apparently, a lot of ORMs do something like this: query.filter(username == bob) to generate
Apparently if you run something like wth:alert('hi') from the console it just works, cross-browser.
Apparently, this call to window.open is not valid under Internet Explorer. The Javascript code
Apparently using the URL is no good - why is this the case, and
Apparently you can easily obtain a client IP address in WCF 3.5 but not

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.