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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:18:52+00:00 2026-05-16T04:18:52+00:00

I have images in separate tables with Delete button and I would like to

  • 0

I have images in separate tables with Delete button and I would like to remove the table of which delete button was clicked.

I have tried $(this).closest("table").remove() and $(this).parents("table").remove() but without success. Nothing happens.

Here’s the HTML:

<table class='".($i % 2 ? "tbl_img_light" : "tbl_img_grey").">
<tr>
<th rowspan='2'>Image here</th>
<td>Description here
</tr>
<tr>
<td><button class='ad_del_img' value='$filename'>Delete</button></td>
</tr>
</table>

It might look messy, took it out of my PHP loops

and JS:
$(".ad_del_img").click(function() {
var file = $(this).val();
dataString = "file="+file;

//$(this).closest("table").remove();

$.ajax({
         type: "POST",
         url: 'controlUI/bin/delete_image.php',
         dataType : 'json',
         data: dataString,
         success: function(data)
         {
           alert("Success");
           $(this).closest("table").remove();
         },
         error: function(XMLHttpRequest, textStatus, errorThrown)
         {
           alert("Error");
         }
       });
return false;
});
  • 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-16T04:18:53+00:00Added an answer on May 16, 2026 at 4:18 am

    The problem is context isn’t maintained by default, but in jQuery 1.4+ you can specify a context, like this:

    $.ajax({
      context: this,  //add this
      type: "POST",
      url: 'controlUI/bin/delete_image.php',
      dataType : 'json',
      data: dataString,
      success: function(data) {
        alert("Success");
        $(this).closest("table").remove();
      },
      error: function(XMLHttpRequest, textStatus, errorThrown) {
        alert("Error");
      }
    });
    

    The context option determines what this is when all of your event handlers for the $.ajax() request run, including success.

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

Sidebar

Related Questions

I have an images folder with a png in it. I would like to
I have a table column like this, where I want to align an image
I'm tinkering with Silverlight 2.0. I have some images, which I currently have a
I have 28,000 images I need to convert into a movie. I tried mencoder
Is it possible to have two background images? For instance, I'd like to have
This is a question which has been asked before ( large-text-and-images-in-sql ) but mainly
I have an sqlite table w/ 500 records each with images stored as blob
I have a few pages which I'd like to have the same background across,
I have images to overlay on google maps by using checkboxes. I made this
I have this ASP.NET MVC application that I now want to separate out the

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.