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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:16:44+00:00 2026-05-13T14:16:44+00:00

I have a table that looks something like this: <table> <tr id=header> <th>Title</th> <th>Title</th>

  • 0

I have a table that looks something like this:

<table>
<tr id="header">
    <th>Title</th>
    <th>Title</th>
</tr>
<tr id="1" class="record">
    <td><a class="delbutton">X</a></td>
    <td>Some Data</td>
</tr>
<tr id="2" class="record">
    <td><a class="delbutton">X</a></td>
    <td>Some Data</td>
</tr>
</table>

And I have a jQuery script:

$(function() {
    $(".delbutton").click(function(){

        //Save the link in a variable called element
        var element = $(this);

        //Find the id of the link that was clicked
        var del_id = element.attr("id");

        //Built a url to send
        var info = 'del_id=' + del_id;
        if(confirm("Are you sure you want to delete this entry?  This cannot be undone.")) {
            $.ajax({
                type: "GET",
                    url: "delete_entry.php",
                    data: info,
                    success: function(){
            }
        });

        $(this).parents(".record").animate({ backgroundColor: "#fbc7c7" }, "fast")
        .animate({ opacity: "hide" }, "slow");
    }
    return false;
    });
});

What I’m trying to do is to delete the header row (id=”header”), or better yet, the remaining table after the last data row has been deleted.

Any guidance would be great

Update:
After following Tom’s recommendation I tried to count the rows.
I tried with:

$('.record').size()

but that always reports the initial number of rows – it never accurately reports the row count after I delete a row. Is it possible to keep track of just the remaining rows somehow?

Resolution
This worked:

$(function() {
    $(".delbutton").click(function(){

        //Save the link in a variable called element
        var element = $(this);

        //Find the id of the link that was clicked
        var del_id = element.attr("id");

        //Built a url to send
        var info = 'del_id=' + del_id;
        if(confirm("Are you sure you want to delete this entry?  This cannot be undone.")) {
            $.ajax({
                type: "GET",
                    url: "delete_entry.php",
                    data: info,
                    success: function(){
            }
        });

        $(this).parents(".record").animate({ backgroundColor: "#fbc7c7" }, "fast")
        .animate({ opacity: "hide" }, "slow");
                    //Remove - don't just hide                        
                    $(this).parents(".record").remove();

                    //If there are no more deleteable rows, delete the header
        if($('.record').length == 0) {
            $('#existTitle').animate({ backgroundColor: "#fbc7c7" }, "fast").animate({ opacity: "hide" }, "slow");
        }
    }
    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-13T14:16:45+00:00Added an answer on May 13, 2026 at 2:16 pm

    Grab the table, I’m assuming you can get it with $(this).parents(“.record”).parents(“table”), check the number of child rows it has and if it’s 1 or 0, remove the element (or fade it out).

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

Sidebar

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.