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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:26:56+00:00 2026-06-08T19:26:56+00:00

UPDATE 1: I’m wondering if it has anything to do with the button being

  • 0

UPDATE 1:

I’m wondering if it has anything to do with the button being within the element which is being deleted, so it would end up deleting the button which does the deleting too? That might not be the problem, I was just typing that I’m thinking.

I’ve just tried:

$( "input.btnX" ).click(function(event) {
    alert("test");
});

and I don’t get an alert… Should I be using live or is it on now because the buttons along with the table are dynamically generated.

ORIGINAL QUESTION:

I have a table (dynamically generated, so I won’t know how many tr’s it has in tbody which looks something like this:

<table>
    <tbody>
        <tr>
            <td>col1</td>
            <td>col2</td>
            <td><input type="button" class="btnX" name="x" value="x" /></td>
        </tr>
        <tr>
            <td>col1</td>
            <td>col2</td>
            <td><input type="button" class="btnX" name="x" value="x" /></td>
        </tr>
    </tbody>
</table>

How do I delete the parent tr if an x button is clicked? So in this example, if the bottom x is clicked, it should remove the bottom tr.

I’ve tried this:

$( "input.btnX" ).click(function(event) {
    $(this).parent('tr').remove();
});

But nothing happens.

  • 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-08T19:26:58+00:00Added an answer on June 8, 2026 at 7:26 pm

    Just use

        $( "input.btnX" ).click(function(event) {
        $(this).parent().parent().remove();
    });
    

    Or

      $( "input.btnX" ).click(function(event) {
            $(this).closest("tr").remove();
        });
    

    As what you are doing is going to the parent which is the tr and then looking for a tr

    See an example here http://jsfiddle.net/gYDUF/

    If your table is beeing rendered by javascript you may also have to change your click on

    $("input.btnX" ).live(click, function(){
    
         $(this).closest("tr").remove();
    }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Update : This is no longer an issue from C# 6, which has introduced
UPDATE Flexslider has a bunch of callback spaces for use which make this possible.
Update : I found almost exact similar question , yet it has slightly different
Update : Properly initialising string with char string[sizeof buffer - 1] has solved the
Update 2018 : This question was asked long before PostCSS existed, and I would
Update: The index.php file here: /public_html/d/index.php includes: /public_html/d/core/source/class.File1.php This Class.File1.php here has this include
[UPDATE] Was just an idiot mistake. See end for solution. I am trying to
UPDATE - I'm probably being daft, see my last update below. I just did
Update : Looks like the query does not throw any timeout. The connection is
Update: I asked the question because the result does not look like how it

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.